get ready for Smarty apc caching
This commit is contained in:
parent
d0d78f3450
commit
50344b19c0
61
bundled-libs/Smarty/libs/plugins/cacheresource.apc.php
Normal file
61
bundled-libs/Smarty/libs/plugins/cacheresource.apc.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* APC CacheResource for Smarty 3.1.x
|
||||
*
|
||||
* CacheResource Implementation based on the KeyValueStore API to use
|
||||
* apc as the storage resource for Smarty's output caching.
|
||||
*
|
||||
*/
|
||||
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if(!function_exists('apc_cache_info'))
|
||||
throw new Exception('APC Template Caching Error: APC is not installed');
|
||||
}
|
||||
/**
|
||||
* Read values for a set of keys from cache
|
||||
*
|
||||
* @param array $keys list of keys to fetch
|
||||
* @return array list of values with the given keys used as indexes
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function read(array $keys)
|
||||
{
|
||||
return apc_fetch($keys);
|
||||
}
|
||||
/**
|
||||
* Save values for a set of keys to cache
|
||||
*
|
||||
* @param array $keys list of values to save
|
||||
* @param int $expire expiration time
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function write(array $keys, $expire=null)
|
||||
{
|
||||
return apc_store($keys, null, $expire);
|
||||
}
|
||||
/**
|
||||
* Remove values from cache
|
||||
*
|
||||
* @param array $keys list of keys to delete
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function delete(array $keys)
|
||||
{
|
||||
foreach ($keys as $k) {
|
||||
apc_delete($k);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Remove *all* values from cache
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
protected function purge()
|
||||
{
|
||||
return apc_clear_cache('user');
|
||||
}
|
||||
}
|
@ -167,6 +167,10 @@ class Serendipity_Smarty extends Smarty
|
||||
Set Smarty caching
|
||||
*/
|
||||
|
||||
// enable for APC in-memory (RAM) storage caching - must be enabled in PHP
|
||||
#apc-cache# $this->addPluginsDir ( SMARTY_DIR . 'plugins/' );
|
||||
#apc-cache# $this->caching_type = 'apc'; //$this->setCachingType ( 'apc' );
|
||||
|
||||
/*
|
||||
Caching is disabled, as long as we haven't figured out on how to use it best here....
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user