Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //@author voltage
- define('C_CONN_MEMCACHED_HOSTNAME', '127.0.0.1');
- define('C_CONN_MEMCACHED_PORT', 11211);
- define('C_CACHE_USE_COMPRESSION', false);
- $memcache = new Memcache();
- $memcache->pconnect(C_CONN_MEMCACHED_HOSTNAME, C_CONN_MEMCACHED_PORT);
- function catchd($varname, $timeout, $carrier, $args = null)
- {
- if(extension_loaded('apc'))
- {
- $j = apc_fetch($varname);
- if(empty($j))
- {
- $j = call_user_func($carrier, $args);
- apc_store
- (
- $varname,
- $j,
- $timeout
- );
- }
- return $j;
- }
- else
- {
- if(extension_loaded('memcache'))
- {
- global $memcache;
- $j = $memcache->get($varname);
- if($j === false)
- {
- $j = call_user_func($carrier, $args);
- $memcache->set
- (
- $varname,
- $j,
- (
- C_CACHE_USE_COMPRESSION
- ? MEMCACHE_COMPRESSED
- : 0
- ),
- $timeout
- );
- }
- return $j;
- }
- else
- {
- return call_user_func($carrier, $args);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment