
Static Public Member Functions | |
| static | clearObjectCache ($name) |
| INSERT BRIEF DESCRIPTION HERE. | |
| static | deleteById ($type, $id) |
| Remove object from cache by ID. | |
| static | deleteByPath ($type, $path) |
| Removes object from cache via its path. | |
| static | dumpCache () |
| Displays detailed cache information in the debug message queue. | |
| static | getById ($type, $id) |
| Retrieve Snap object from cache by ID. | |
| static | getByPath ($type, $path) |
| Retrieves object from cache by path. | |
| static | getObjectCache ($name) |
| INSERT BRIEF DESCRIPTION HERE. | |
| static | getPathsById ($type, $id) |
| Retrieves all paths in cache for object with given ID. | |
| static | init ($useCache=true, $useApc=true) |
| Initializes the cache manager. | |
| static | putById ($type, $id, $obj) |
| Puts a Snap object in the cache, identified by ID. | |
| static | putByPath ($type, $path, $obj, $isCanon=false) |
| Put object into path cache. | |
| static | setEnableAPC ($enable, $clear=false) |
| Enables/disables usage of the APC cache. | |
| static | setEnableCache ($enable, $clear=false) |
| Enables/disables the plain old cache. | |
| static | showStats () |
| Displays cache statistics in the debug message queue. | |
| static | updateById ($type, $id) |
| Update object in cache. | |
| static | usingApc () |
| Returns whether APC is currently enabled. | |
| static | usingCache () |
| Returnes whether plain cache is in use. | |
Static Private Attributes | |
| static | $APC_EXISTS |
| static | $CACHE_ID |
| static | $CACHE_PATH |
| static | $ID_CACHE_HITS |
| static | $ID_CACHE_MISSES |
| static | $ID_TO_PATH |
| static | $PATH_CACHE_HITS |
| static | $PATH_CACHE_MISSES |
| static | $TYPE_MAP |
| static | $useApc |
| static | $useCache |
For internal use only.
The cache stores Snap objects for the duration of a script's execution, with the goal of improving performance. The cache manager can also store objects in the APC cache, so that they continue to exist even after the script exits and can be used by future runs of the script. Currently, the APC cache is broken and is disabled by default. Do not enable it if you plan to have non-corrupt data.
Users of the Snap2 API should not use this class directly. Cache management features are available from the Snap2 management class.
Definition at line 17 of file SnapCache.php5.
| static SnapCache::clearObjectCache | ( | $ | name | ) | [static] |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
| $name | [TYPE]: DESCRIPTION |
Definition at line 332 of file SnapCache.php5.
Referenced by SnapPermission::commit(), SnapPermission::grantPrivilege(), and SnapPermission::revokePrivilege().
| static SnapCache::deleteById | ( | $ | type, | |
| $ | id | |||
| ) | [static] |
Remove object from cache by ID.
For internal use only.
Also removes entries in path cache that point to the same object. Object is not actually "deleted", however.
| $type | [string]: type of object to delete (e.g., 'Directory') | |
| $id | [mixed]: ID of object to delete |
Definition at line 187 of file SnapCache.php5.
| static SnapCache::deleteByPath | ( | $ | type, | |
| $ | path | |||
| ) | [static] |
Removes object from cache via its path.
For internal use only.
This method does not remove other paths to the object in the cache, or the ID cache entry.
| $type | [string]: type of object to remove from path cache (e.g., 'Directory', etc.) | |
| $path | [string]: path of object |
Definition at line 286 of file SnapCache.php5.
| static SnapCache::dumpCache | ( | ) | [static] |
Displays detailed cache information in the debug message queue.
For internal use only.
Definition at line 387 of file SnapCache.php5.
References SErrorManager::setDebug().
| static SnapCache::getById | ( | $ | type, | |
| $ | id | |||
| ) | [static] |
Retrieve Snap object from cache by ID.
For internal use only.
If object is not in cache, and APC is enabled, then APC is consulted to retrieve the object, which is then put in the regular cache and returned. If object is not in cache or APC, then null is returned.
| $type | [string]: type of object to retrieve (e.g., 'Directory', etc.) | |
| $id | [mixed]: ID of object to retrieve |
Definition at line 159 of file SnapCache.php5.
Referenced by SnapDirectory::listContents(), SnapFile::loadMetadata(), SnapFile::loadPermission(), SnapResourceUserPermission::retrieve(), SnapResourceGroupPermission::retrieve(), SnapDirectoryUserPermission::retrieve(), SnapDirectoryGroupPermission::retrieve(), SnapVersion::retrieve(), SnapResource::retrieve(), SnapDirectory::retrieve(), and SnapPermissionObject::warmCache().
| static SnapCache::getByPath | ( | $ | type, | |
| $ | path | |||
| ) | [static] |
Retrieves object from cache by path.
For internal use only.
If no object is found in the cache by the given path, then APC is consulted. If there is an object in APC for the path, then it is put in the regular cache. If it is not in APC or the regular cache, null is returned.
| $type | [string]: type of object to retrieve from cache (e.g., 'Directory', etc.) | |
| $path | [string]: path by which to retrieve object |
Definition at line 234 of file SnapCache.php5.
Referenced by SnapVersion::lookup(), SnapResource::lookup(), and SnapDirectory::lookup().
| static SnapCache::getObjectCache | ( | $ | name | ) | [static] |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
| $name | [TYPE]: DESCRIPTION |
Definition at line 346 of file SnapCache.php5.
Referenced by SnapPermission::commit(), SnapPermission::grantPrivilege(), and SnapPermission::revokePrivilege().
| static SnapCache::getPathsById | ( | $ | type, | |
| $ | id | |||
| ) | [static] |
Retrieves all paths in cache for object with given ID.
For internal use only.
| $type | [string]: type of object to retrieve (e.g., 'Directory', etc.) | |
| $id | [mixed]: ID of object to retrieve paths for |
Definition at line 266 of file SnapCache.php5.
Referenced by SnapFile::loadCanonicalPath().
| static SnapCache::init | ( | $ | useCache = true, |
|
| $ | useApc = true | |||
| ) | [static] |
Initializes the cache manager.
For internal use only.
This method should only be called by Snap2::init.
| $useCache | [boolean]: whether to use the plain cache | |
| $useApc | [boolean]: whether to use the APC cache |
Definition at line 68 of file SnapCache.php5.
References $useApc, and $useCache.
Referenced by Snap2::init(), and Snap2::reinit().
| static SnapCache::putById | ( | $ | type, | |
| $ | id, | |||
| $ | obj | |||
| ) | [static] |
Puts a Snap object in the cache, identified by ID.
For internal use only.
Use updatebyId() if object is already in the cache. This method will perform a write-through to APC if use of the APC cache is enabled.
| $type | [string]: object type (e.g., 'Directory', etc.) | |
| $id | [mixed]: ID of object | |
| $obj | [SnapObject]: actual object |
Definition at line 139 of file SnapCache.php5.
Referenced by SnapDirectory::createDirectory(), SnapDirectory::createResource(), SnapDirectory::listContents(), SnapFile::loadMetadata(), SnapFile::loadPermission(), SnapResourceUserPermission::retrieve(), SnapResourceGroupPermission::retrieve(), SnapDirectoryUserPermission::retrieve(), SnapDirectoryGroupPermission::retrieve(), SnapVersion::retrieve(), SnapResource::retrieve(), SnapDirectory::retrieve(), and SnapPermissionObject::warmCache().
| static SnapCache::putByPath | ( | $ | type, | |
| $ | path, | |||
| $ | obj, | |||
| $ | isCanon = false | |||
| ) | [static] |
Put object into path cache.
For internal use only.
In addition to putting the object in the path cache, it also puts the object in the regular ID-based cache. You can also specify if the path is the canonical path of the object, so that canonical path lookups will be faster.
| $type | [string]: type of object (e.g., 'Directory', etc.) | |
| $path | [string]: Snap path | |
| $obj | [SnapObject]: object to put into the cache | |
| $isCanon | [boolean]: whether $path is the canonical path to the object |
Definition at line 209 of file SnapCache.php5.
Referenced by SnapDirectory::listContents(), and SnapFile::loadCanonicalPath().
| static SnapCache::setEnableAPC | ( | $ | enable, | |
| $ | clear = false | |||
| ) | [static] |
Enables/disables usage of the APC cache.
For internal use only.
Call Snap2::setEnableAPC() instead (which just calls this method, but does some other things as well).
| $enable | [boolean]: whether to enable APC cache | |
| $clear | [boolean]: whether to clear out the existing entries in the APC cache if disabling |
Definition at line 84 of file SnapCache.php5.
Referenced by Snap2::setEnableAPC().
| static SnapCache::setEnableCache | ( | $ | enable, | |
| $ | clear = false | |||
| ) | [static] |
Enables/disables the plain old cache.
Call Snap2::setEnableCache() instead (which calls this method, but does some other things as well).
| $enable | [boolean]: whether to enable to cache | |
| $clear | [boolean]: whether to clear out the cache if disabling |
Definition at line 108 of file SnapCache.php5.
Referenced by SnapPermission::commit(), and Snap2::setEnableCache().
| static SnapCache::showStats | ( | ) | [static] |
Displays cache statistics in the debug message queue.
For internal use only.
Definition at line 355 of file SnapCache.php5.
References SErrorManager::setDebug().
| static SnapCache::updateById | ( | $ | type, | |
| $ | id | |||
| ) | [static] |
Update object in cache.
For internal use only.
This method only exists because APC caching is currently write-through, not write-back or write-combining, so we need to explicitly have an object written to the APC cache when it is changed, or it won't be properly stored. Call this method whenever an object changes.
| $type | [string]: object type (e.g., 'Directory', etc.) | |
| $id | [mixed]: ID of object |
Definition at line 309 of file SnapCache.php5.
Referenced by SnapMetadata::commit(), SnapResource::loadActiveVersion(), SnapFile::loadCanonicalParent(), SnapFile::loadCanonicalPath(), SnapVersion::loadContentModule(), SnapResource::loadDevVersion(), SnapResource::loadLiveVersion(), SnapDirectory::loadMaxDirOrdinal(), SnapResource::loadMaxOrdinal(), SnapDirectory::loadMaxResOrdinal(), SnapFile::loadMetadata(), SnapFile::loadPermission(), SnapVersion::loadPrevVersion(), SnapVersion::loadResource(), SnapVersion::populate(), SnapMetadata::populate(), SnapFile::populate(), and SnapFile::restore().
| static SnapCache::usingApc | ( | ) | [static] |
Returns whether APC is currently enabled.
Definition at line 97 of file SnapCache.php5.
| static SnapCache::usingCache | ( | ) | [static] |
Returnes whether plain cache is in use.
Definition at line 125 of file SnapCache.php5.
Referenced by SnapPermission::commit().
SnapCache::$APC_EXISTS [static, private] |
Whether we can even use APC (in case the extension is disabled)
Definition at line 46 of file SnapCache.php5.
SnapCache::$CACHE_ID [static, private] |
ID cache: cache objects by their type and ID
Definition at line 19 of file SnapCache.php5.
SnapCache::$CACHE_PATH [static, private] |
Path cache: cache objects by their type and path
Definition at line 29 of file SnapCache.php5.
SnapCache::$ID_CACHE_HITS [static, private] |
Number of times ID cache was consulted and the object was found in cache
Definition at line 34 of file SnapCache.php5.
SnapCache::$ID_CACHE_MISSES [static, private] |
Number of times ID cache was consulted and object was not in cache
Definition at line 32 of file SnapCache.php5.
SnapCache::$ID_TO_PATH [static, private] |
Relates object IDs to entries in the path cache
Definition at line 27 of file SnapCache.php5.
SnapCache::$PATH_CACHE_HITS [static, private] |
Number of times path cache was consulted and the object was found in cache
Definition at line 38 of file SnapCache.php5.
SnapCache::$PATH_CACHE_MISSES [static, private] |
Number of times path cache was consulted and object was not in cache
Definition at line 36 of file SnapCache.php5.
SnapCache::$TYPE_MAP [static, private] |
Used to generate APC cache keys; instead of 'Directory' we'd use 'D', etc.
Definition at line 49 of file SnapCache.php5.
SnapCache::$useApc [static, private] |
SnapCache::$useCache [static, private] |
Whether the plain old cache is in use
Definition at line 43 of file SnapCache.php5.
Referenced by init().
1.5.6