phpDocumentor GalleryCore
Classes
[ class tree: GalleryCore ] [ index: GalleryCore ] [ all elements ]

Class: GalleryDataCache

Source Location: /modules/core/classes/GalleryDataCache.class

Class GalleryDataCache

Class Overview

Utility class for caching data

Very useful in the case where retrieving or building data sets is expensive, and the data doesn't change during the lifetime of the request. This class serves as a hash table where any data class can store and retrieve cached data.

Located in /modules/core/classes/GalleryDataCache.class [line 45]



		
		
		
		

Methods

[ Top ]
Method Summary
void   cachePermissions()   Store the given permission => ids mapping in the session cache
void   clearPermissionCache()   Clear permission cache for active user.
boolean   containsKey()   Does the cache contain the key specified?
mixed   get()   Retrieve data from the cache
array   getAllKeys()   Return all the keys in the cache
string   getCachePath()   Given a path info descriptor, return the path to the appropriate cache file.
array   getCacheTuple()   For a given id, return a tuple with the breakdown of the id. The caching mechanism uses this to determine where in the cache tree to place the file. The breakdown happens according to the digits of the id. The first element returned is the hundreds digit, the second element is the tens digit.
mixed   &getFromDisk()   Get the file from disk. PathInfo is of the form that can be passed to getCachePath
array   getPageData()   Get page data from the cache.
boolean   hasPermission()   Look up the given permission in the cache. Return true if the permission exists in the cache, false if it doesn't. A return of false doesn't mean that the user doesn't have the permission -- just that it's not in the cache.
boolean   &isFileCachingEnabled()   Is caching to disk enabled?
boolean   isMemoryCachingEnabled()   Is in-memory caching enabled?
void   put()   Store data in the cache You must provide a unique key. Existing keys are overwritten.
void   putByReference()   Store a reference to the data in the cache
GalleryStatus   putPageData()   Store page data from the cache.
void   putToDisk()   Put the specified data into a cache file from disk. PathInfo is of the form that can be passed to getCachePath.
void   remove()   Remove data from the cache
void   removeByPattern()   Remove data from the cache
void   removeFromDisk()   Remove the cache file from disk. PathInfo is of the form that can be passed to getCachePath
GalleryStatus   removePageData()   Remove all cached page data for the given item ids
void   reset()   Empty the cache of all but protected entries
void   setFileCachingEnabled()   Turn caching to disk on or off
void   setMemoryCachingEnabled()   Turn in-memory caching on or off
GalleryStatus   shouldCache()   Should we use the cache for this page or not? Right now we cache a page if it's a GET request, the browser hasn't specified that it wants uncached data, and the caching policy for the given user class is appropriate.
GalleryStatus   _cleanPageDataCache()   Delete value of obsolete cache data.
array   &_getCache()   Get the static cache
array   _getExtraPageCacheKey()   Returns session related page cache key, eg. to make the page cache language sensitive
void   _performMaintenance()   Perform some pruning of our cache to prevent it from growing too large when we're doing exceptionally long operations like adding many items in one request.

[ Top ]
Methods
cachePermissions  [line 489]

  void cachePermissions( mixed $ids, string $permission  )

Store the given permission => ids mapping in the session cache

Parameters:
mixed   $ids:  item ids (can be an array of ids or a single id)
string   $permission: 


[ Top ]
clearPermissionCache  [line 577]

  void clearPermissionCache( )

Clear permission cache for active user.



[ Top ]
containsKey  [line 213]

  boolean containsKey( string $key  )

Does the cache contain the key specified?

Parameters:
string   $key: 

API Tags:
Return:  true if the cache contains the key given


[ Top ]
get  [line 196]

  mixed get( string $key  )

Retrieve data from the cache

Parameters:
string   $key: 

API Tags:
Return:  the cached data


[ Top ]
getAllKeys  [line 225]

  array getAllKeys( )

Return all the keys in the cache


API Tags:
Return:  string keys


[ Top ]
getCachePath  [line 409]

  string getCachePath( $pathInfo  )

Given a path info descriptor, return the path to the appropriate cache file.

Path info contains the following variables: type: entity, derivative, derivative-relative, fast-download, module, module-data, theme, local-url-map itemId: the item id id: (module, theme only) a refinement of the type

Parameters:
   $pathInfo: 

API Tags:
Return:  the path


[ Top ]
getCacheTuple  [line 387]

  array getCacheTuple( int $id  )

For a given id, return a tuple with the breakdown of the id. The caching mechanism uses this to determine where in the cache tree to place the file. The breakdown happens according to the digits of the id. The first element returned is the hundreds digit, the second element is the tens digit.

0..9 => 0, 0 10..19 => 0, 1 20..29 => 0, 2 ... 100..109 => 1, 0 110..119 => 1, 1

Parameters:
int   $id: 

API Tags:
Return:  the tuple


[ Top ]
getFromDisk  [line 282]

  mixed &getFromDisk( array $pathInfo  )

Get the file from disk. PathInfo is of the form that can be passed to getCachePath

Parameters:
array   $pathInfo:  the path info

API Tags:
Return:  object data
See:  GalleryDataCache::getCachePath


[ Top ]
getPageData  [line 593]

  array getPageData( string $type, mixed $keyData  )

Get page data from the cache.

Parameters:
string   $type:  the page type
mixed   $keyData:  data to use to generate the unique key for this cache entry

API Tags:
Return:  GalleryStatus a status code string the page data


[ Top ]
hasPermission  [line 553]

  boolean hasPermission( int $id, string $permission  )

Look up the given permission in the cache. Return true if the permission exists in the cache, false if it doesn't. A return of false doesn't mean that the user doesn't have the permission -- just that it's not in the cache.

Parameters:
int   $id:  the item id
string   $permission: 


[ Top ]
isFileCachingEnabled  [line 261]

  boolean &isFileCachingEnabled( )

Is caching to disk enabled?



[ Top ]
isMemoryCachingEnabled  [line 73]

  boolean isMemoryCachingEnabled( )

Is in-memory caching enabled?


API Tags:
Return:  true if it's enabled


[ Top ]
put  [line 95]

  void put( string $key, mixed $data, [boolean $protected = false]  )

Store data in the cache You must provide a unique key. Existing keys are overwritten.

Parameters:
string   $key: 
mixed   $data: 
boolean   $protected:  should this key survive a reset call?


[ Top ]
putByReference  [line 154]

  void putByReference( string $key, &$data, [boolean $protected = false], mixed $data  )

Store a reference to the data in the cache

You must provide a unique key. Existing keys are overwritten.

Parameters:
string   $key: 
mixed   $data: 
boolean   $protected:  (optional) should this key survive a reset call?
   &$data: 


[ Top ]
putPageData  [line 663]

  GalleryStatus putPageData( string $type, int $itemId, mixed $keyData, string $value  )

Store page data from the cache.

Parameters:
string   $type:  the page type
int   $itemId:  the itemId of the item this page is rendering
mixed   $keyData:  data to use to generate the unique key for this cache entry
string   $value:  the page data

API Tags:
Return:  a status code


[ Top ]
putToDisk  [line 355]

  void putToDisk( array $pathInfo, &$data, [array $requiredClasses = array()], mixed $data  )

Put the specified data into a cache file from disk. PathInfo is of the form that can be passed to getCachePath.

Parameters:
array   $pathInfo:  the path info
mixed   $data:  the object data
array   $requiredClasses:  classes that must be loaded in order to retrieve this data
   &$data: 

API Tags:
See:  GalleryDataCache::getCachePath


[ Top ]
remove  [line 117]

  void remove( string $key  )

Remove data from the cache

Parameters:
string   $key: 


[ Top ]
removeByPattern  [line 132]

  void removeByPattern( string $pattern  )

Remove data from the cache

Parameters:
string   $pattern:  regexp


[ Top ]
removeFromDisk  [line 313]

  void removeFromDisk( array $pathInfo  )

Remove the cache file from disk. PathInfo is of the form that can be passed to getCachePath

Parameters:
array   $pathInfo:  the path info

API Tags:
See:  GalleryDataCache::getCachePath


[ Top ]
removePageData  [line 738]

  GalleryStatus removePageData( mixed $itemIds  )

Remove all cached page data for the given item ids

Parameters:
mixed   $itemIds:  one item id, or an array of item ids

API Tags:
Return:  a status code


[ Top ]
reset  [line 238]

  void reset( [boolean $purgeProtected = false]  )

Empty the cache of all but protected entries

Parameters:
boolean   $purgeProtected:  (optional) purge protected also?


[ Top ]
setFileCachingEnabled  [line 271]

  void setFileCachingEnabled( boolean $bool  )

Turn caching to disk on or off

Parameters:
boolean   $bool: 


[ Top ]
setMemoryCachingEnabled  [line 82]

  void setMemoryCachingEnabled( boolean $bool  )

Turn in-memory caching on or off

Parameters:
boolean   $bool: 


[ Top ]
shouldCache  [line 755]

  GalleryStatus shouldCache( string $action, string $type  )

Should we use the cache for this page or not? Right now we cache a page if it's a GET request, the browser hasn't specified that it wants uncached data, and the caching policy for the given user class is appropriate.

Parameters:
string   $action: 
string   $type:  the page type

API Tags:
Return:  a status code


[ Top ]
_cleanPageDataCache  [line 827]

  GalleryStatus _cleanPageDataCache( )

Delete value of obsolete cache data.


API Tags:
Return:  a status code


[ Top ]
_getCache  [line 54]

  array &_getCache( )

Get the static cache


API Tags:
Return:  the cache
Staticvar:  cache $cache: the singleton cache
Access:  private


[ Top ]
_getExtraPageCacheKey  [line 802]

  array _getExtraPageCacheKey( )

Returns session related page cache key, eg. to make the page cache language sensitive


API Tags:
Return:  GalleryStatus a status code string extra cache key

Information Tags:
Todo:  The extra key for exif module is a quick fix, not a permanent fix; it should be cached on the block level not on page level.

[ Top ]
_performMaintenance  [line 178]

  void _performMaintenance( )

Perform some pruning of our cache to prevent it from growing too large when we're doing exceptionally long operations like adding many items in one request.


API Tags:
Access:  private


[ Top ]

Documentation generated on Fri, 08 Oct 2010 04:57:17 -0700 by phpDocumentor 1.3.0RC6