| 1 | ###################################################################### | ||||||||||
| 2 | # $Id: YAMLCache.pm,v 1.2 2005/10/26 16:18:30 nachbaur Exp $ | ||||||||||
| 3 | # Copyright (C) 2005 Michael Nachbaur All Rights Reserved | ||||||||||
| 4 | # | ||||||||||
| 5 | # Software distributed under the License is distributed on an "AS | ||||||||||
| 6 | # IS" basis, WITHOUT WARRANTY OF ANY KIND, either expressed or | ||||||||||
| 7 | # implied. See the License for the specific language governing | ||||||||||
| 8 | # rights and limitations under the License. | ||||||||||
| 9 | ###################################################################### | ||||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | package Cache::YAMLCache; | ||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use vars qw( @ISA $VERSION ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use Cache::FileCache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use Cache::CacheUtils qw ( Assert_Defined Build_Path Static_Params ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use Cache::YAMLBackend; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | $VERSION = "0.01"; | |||||||||
| 22 | |||||||||||
| 23 | 1 | @ISA = qw ( Cache::FileCache ); | |||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | # by default, the root of the cache is located in 'YAMLCache'. On a | ||||||||||
| 27 | # UNIX system, this will appear in "/tmp/YAMLCache/" | ||||||||||
| 28 | |||||||||||
| 29 | 1 | my $DEFAULT_CACHE_ROOT = "YAMLCache"; | |||||||||
| 30 | |||||||||||
| 31 | sub _Get_Backend | ||||||||||
| 32 | 0 | ▶ | { | ||||||||
|
Subroutine
_Get_Backend: not called CC=1 SCAR=6.9
| |||||||||||
| 33 | 0 | my ( $p_optional_cache_root ) = Static_Params( @_ ); | |||||||||
| 34 | |||||||||||
| 35 | 0 | return new Cache::YAMLBackend( _Build_Cache_Root( $p_optional_cache_root ) ); | |||||||||
| 36 | |||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | sub _Get_Cache | ||||||||||
| 41 | 0 | ▶ | { | ||||||||
|
Subroutine
_Get_Cache: not called CC=2 SCAR=17.9
| |||||||||||
| 42 | 0 | my ( $p_namespace, $p_optional_cache_root ) = Static_Params( @_ ); | |||||||||
| 43 | |||||||||||
| 44 | 0 | Assert_Defined( $p_namespace ); | |||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | if ( defined $p_optional_cache_root ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | { | ||||||||||
| 48 | 0 | return new Cache::YAMLCache( { 'namespace' => $p_namespace, | |||||||||
| 49 | 'cache_root' => $p_optional_cache_root } ); | ||||||||||
| 50 | } | ||||||||||
| 51 | else | ||||||||||
| 52 | { | ||||||||||
| 53 | 0 | return new Cache::YAMLCache( { 'namespace' => $p_namespace } ); | |||||||||
| 54 | } | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | sub _initialize_file_backend | ||||||||||
| 60 | 0 | ▶ | { | ||||||||
|
Subroutine
_initialize_file_backend: not called CC=1 SCAR=6.9
| |||||||||||
| 61 | 0 | my ( $self ) = @_; | |||||||||
| 62 | |||||||||||
| 63 | 0 | $self->_set_backend( new Cache::YAMLBackend( $self->_get_initial_root( ), | |||||||||
| 64 | $self->_get_initial_depth( ), | ||||||||||
| 65 | $self->_get_initial_umask( ) )); | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 1 | 1; | |||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||