cid = $cid; $cache->data = is_object($data) ? memcache_clone($data) : $data; $cache->created = time(); $cache->expire = $expire; $cache->headers = $headers; // Save to memcache if ($expire == CACHE_PERMANENT || $expire > time()) { dmemcache_set($cid, $cache, $expire, $table); } else if ($expire == CACHE_TEMPORARY) { // A compromise for CACHE_TEMPORARY: Cache for three minutes. dmemcache_set($cid, $cache, 180, $table); } } /** * * Expire data from the cache. If called without arguments, expirable * entries will be cleared from the cache_page table. * * @param $cid * If set, the cache ID to delete. Otherwise, all cache entries that can * expire are deleted. * * @param $table * If set, the table $table to delete from. Mandatory * argument if $cid is set. * * @param $wildcard * If set to TRUE, the $cid is treated as a substring * to match rather than a complete ID. The match is a right hand * match. If '*' is given as $cid, the table $table will be emptied. */ function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE) { // Memcache logic is simpler because memcache doesn't have a minimum cache // lifetime consideration (it handles it internally), and doesn't support // wildcards. $bin = empty($table) ? 'cache' : $table; if (empty($cid) || $cid == '*') { dmemcache_flush($table); } else { dmemcache_delete($cid, $table); } } /** * Provide a substitute clone() function for PHP4. This is a copy of drupal_clone * because common.inc isn't included early enough in the bootstrap process to * be able to depend on drupal_clone. */ function memcache_clone($object) { return version_compare(phpversion(), '5.0') < 0 ? $object : clone($object); }