Open Journal Systems  3.3.0
GenericCache Class Reference
Inheritance diagram for GenericCache:
APCCache MemcacheCache XCacheCache

Public Member Functions

 __construct ($context, $cacheId, $fallback)
 
 close ()
 
 flush ()
 
 get ($id)
 
 getCache ($id)
 
 getCacheId ()
 
 getCacheTime ()
 
 getContext ()
 
 set ($id, $value)
 
 setCache ($id, $value)
 
 setEntireCache ($contents)
 

Data Fields

 $cacheId
 
 $cacheMiss
 
 $context
 
 $fallback
 

Detailed Description

Provides implementation-independent caching. Although this class is intended to be overridden with a more specific implementation, it can be used as the null cache.

Definition at line 23 of file GenericCache.inc.php.

Constructor & Destructor Documentation

◆ __construct()

GenericCache::__construct (   $context,
  $cacheId,
  $fallback 
)

Instantiate a cache.

Reimplemented in APCCache, and XCacheCache.

Definition at line 50 of file GenericCache.inc.php.

References $cacheId, $context, and $fallback.

Member Function Documentation

◆ close()

GenericCache::close ( )

Close the cache. (Optionally overridden by subclasses.)

Reimplemented in MemcacheCache.

Definition at line 115 of file GenericCache.inc.php.

◆ flush()

GenericCache::flush ( )

Flush the cache.

Reimplemented in MemcacheCache, APCCache, and XCacheCache.

Definition at line 79 of file GenericCache.inc.php.

Referenced by setEntireCache().

◆ get()

GenericCache::get (   $id)

Get an object from cache, using the fallback if necessary.

Definition at line 60 of file GenericCache.inc.php.

References getCache().

◆ getCache()

GenericCache::getCache (   $id)

Get an object from the cache. This function should be overridden by subclasses.

Parameters
$id

Reimplemented in MemcacheCache, XCacheCache, and APCCache.

Definition at line 99 of file GenericCache.inc.php.

References $cacheMiss.

Referenced by get().

◆ getCacheId()

GenericCache::getCacheId ( )

◆ getCacheTime()

GenericCache::getCacheTime ( )

Get the time at which the data was cached.

Reimplemented in MemcacheCache, APCCache, and XCacheCache.

Definition at line 135 of file GenericCache.inc.php.

◆ getContext()

GenericCache::getContext ( )

◆ set()

GenericCache::set (   $id,
  $value 
)

Set an object in the cache. This function should be overridden by subclasses.

Definition at line 72 of file GenericCache.inc.php.

References setCache().

◆ setCache()

GenericCache::setCache (   $id,
  $value 
)

Set an object in the cache. This function should be overridden by subclasses.

Parameters
$id
$value

Reimplemented in MemcacheCache, XCacheCache, and APCCache.

Definition at line 109 of file GenericCache.inc.php.

Referenced by set(), and setEntireCache().

◆ setEntireCache()

GenericCache::setEntireCache (   $contents)

Set the entire contents of the cache. May (should) be overridden by subclasses.

Parameters
$arrayarray of id -> value pairs

Reimplemented in MemcacheCache, APCCache, and XCacheCache.

Definition at line 87 of file GenericCache.inc.php.

References flush(), and setCache().

Field Documentation

◆ $cacheId

GenericCache::$cacheId

The ID of this particular cache within the context

Definition at line 33 of file GenericCache.inc.php.

Referenced by XCacheCache\__construct(), APCCache\__construct(), MemcacheCache\__construct(), __construct(), and getCacheId().

◆ $cacheMiss

GenericCache::$cacheMiss

◆ $context

GenericCache::$context

The unique string identifying the context of this cache. Must be suitable for a filename.

Definition at line 28 of file GenericCache.inc.php.

Referenced by XCacheCache\__construct(), APCCache\__construct(), MemcacheCache\__construct(), __construct(), and getContext().

◆ $fallback

GenericCache::$fallback

The getter fallback callback (for a cache miss) This function is called with two parameters:

  1. The cache object that is suffering a miss
  2. The id of the value to fetch The function is responsible for loading data into the cache, using setEntireCache or setCache.

Definition at line 45 of file GenericCache.inc.php.

Referenced by XCacheCache\__construct(), APCCache\__construct(), MemcacheCache\__construct(), and __construct().


The documentation for this class was generated from the following file: