1<?php 2 3 4interface memcache_interface{ 5 /* initialization of the driver. If the driver needs destructor function, it should register it for self. */ 6 public static function init(); 7 8 /* the driver is emulated (no performance boost). */ 9 public static function emulated(); 10 11 /* returns the backend driver as string (which is either "wincache" or "apc" currently or "fake" if neither is supported, and using filesys-caching instead.) */ 12 public static function driver(); 13 14 /* add one entry, if it does not exists already. returns boolean success (false if key already exists or something went wrong) 15 if ttl parameter is given and positive, it will set time-to-live, else it will remain until cache clear. */ 16 public static function add($key,$val,$ttl = 0); 17 18 /* set one entry: create new or overwrite old value. returns boolean success (false if something went wrong) 19 if ttl parameter is given and positive, it will set time-to-live, else it will remain until cache clear. */ 20 public static function set($key,$val,$ttl = 0); 21 22 /* checks if a key exists. returns boolean. */ 23 public static function exists($key); 24 25 /* deletes data by key. returns boolean. */ 26 public static function del($key); 27 28 /* retrieves a value. returns retrieved value or null. $success out-parameter can be checked to check success (you may have false, null, 0, or "" as stored value). */ 29 public static function get($key,&$success = false); 30 31 /* clears the entire cache. (note: server-wide, so clears cache for every code that uses the same driver). returns boolean success (which should be always true) */ 32 public static function clear(); 33 34} 35if (!class_exists('memcache')){ 36 if (extension_loaded('apc') || extension_loaded('apcu')){ 37 require_once('memcache_apc.class.php'); 38 class_alias('memcache_apc','memcache'); 39 } 40 elseif(extension_loaded('wincache')){ 41 require_once('memcache_wincache.class.php'); 42 class_alias('memcache_wincache','memcache'); 43 } 44 else{ 45 require_once('memcache_fakecache.class.php'); 46 class_alias('memcache_fakecache','memcache'); 47 } 48}