{
    "mode": "perldoc",
    "parameter": "Cache::BaseCache",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Cache%3A%3ABaseCache/json",
    "generated": "2026-06-09T13:39:44Z",
    "synopsis": "Cache::BaseCache is to be used as a superclass for cache implementations. The most effective way\nto use BaseCache is to use the protected setbackend method, which will be used to retrieve the\npersistence mechanism. The subclass can then inherit the BaseCache's implementation of get, set,\netc. However, due to the difficulty inheriting static methods in Perl, the subclass will likely\nneed to explicitly implement Clear, Purge, and Size. Also, a factory pattern should be used to\ninvoke the completeinitialization routine after the object is constructed.\npackage Cache::MyCache;\nuse vars qw( @ISA );\nuse Cache::BaseCache;\nuse Cache::MyBackend;\n@ISA = qw( Cache::BaseCache );\nsub new\n{\nmy ( $self ) = new( @ );\n$self->completeinitialization( );\nreturn $self;\n}\nsub new\n{\nmy ( $proto, $poptionshashref ) = @;\nmy $class = ref( $proto ) || $proto;\nmy $self = $class->SUPER::new( $poptionshashref );\n$self->setbackend( new Cache::MyBackend( ) );\nreturn $self;\n}\nsub Clear\n{\nforeach my $namespace ( Namespaces( ) )\n{\nGetBackend( )->deletenamespace( $namespace );\n}\n}\nsub Purge\n{\nforeach my $namespace ( Namespaces( ) )\n{\nGetCache( $namespace )->purge( );\n}\n}\nsub Size\n{\nmy $size = 0;\nforeach my $namespace ( Namespaces( ) )\n{\n$size += GetCache( $namespace )->size( );\n}\nreturn $size;\n}",
    "sections": {
        "NAME": {
            "content": "Cache::BaseCache -- abstract cache base class\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "BaseCache provides functionality common to all instances of a cache. It differs from the\nCacheUtils package insofar as it is designed to be used as superclass for cache implementations.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "Cache::BaseCache is to be used as a superclass for cache implementations. The most effective way\nto use BaseCache is to use the protected setbackend method, which will be used to retrieve the\npersistence mechanism. The subclass can then inherit the BaseCache's implementation of get, set,\netc. However, due to the difficulty inheriting static methods in Perl, the subclass will likely\nneed to explicitly implement Clear, Purge, and Size. Also, a factory pattern should be used to\ninvoke the completeinitialization routine after the object is constructed.\n\npackage Cache::MyCache;\n\nuse vars qw( @ISA );\nuse Cache::BaseCache;\nuse Cache::MyBackend;\n\n@ISA = qw( Cache::BaseCache );\n\nsub new\n{\nmy ( $self ) = new( @ );\n\n$self->completeinitialization( );\n\nreturn $self;\n}\n\nsub new\n{\nmy ( $proto, $poptionshashref ) = @;\nmy $class = ref( $proto ) || $proto;\nmy $self = $class->SUPER::new( $poptionshashref );\n$self->setbackend( new Cache::MyBackend( ) );\nreturn $self;\n}\n\n\nsub Clear\n{\nforeach my $namespace ( Namespaces( ) )\n{\nGetBackend( )->deletenamespace( $namespace );\n}\n}\n\n\nsub Purge\n{\nforeach my $namespace ( Namespaces( ) )\n{\nGetCache( $namespace )->purge( );\n}\n}\n\n\nsub Size\n{\nmy $size = 0;\n\nforeach my $namespace ( Namespaces( ) )\n{\n$size += GetCache( $namespace )->size( );\n}\n\nreturn $size;\n}\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Cache::Cache, Cache::FileCache, Cache::MemoryCache\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Original author: DeWitt Clinton <dewitt@unto.net>\n\nLast author: $Author: dclinton $\n\nCopyright (C) 2001-2003 DeWitt Clinton\n",
            "subsections": []
        }
    },
    "summary": "Cache::BaseCache -- abstract cache base class",
    "flags": [],
    "examples": [],
    "see_also": []
}