Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 91947fd30f
Fetching contributors…

Cannot retrieve contributors at this time

90 lines (83 sloc) 1.848 kB
<?php
class Memcached
{
// public function connect($host, $port )
// {
// //ham nay hem lam j het.
// }
public function addServer($host, $port )
{
//ham nay hem lam j het.
}
public function get ($key , $cache_cb = null, &$cas_token = null)
{
$cache = FileCache::getInstance();
//$result = $cache->get($key);
return $cache->get($key);
}
public function set ( $key , $value, $expiration = 0)
{
$cache = FileCache::getInstance();
//echo $value;
$cache->set($key, $value);
}
public function remove ($key)
{
$cache = FileCache::getInstance();
$result = @$cache->delete($key);
}
public function add( $key , $value, $expiration = 0)
{
$cache = FileCache::getInstance();
//echo $value;
$cache->add($key, $value);
}
public function flush ($delay = 0)
{
$default_dir = dirname(dirname(__FILE__))."/cache";
foreach (new DirectoryIterator($default_dir) as $fileInfo)
{
$filename = $fileInfo->getFileName();
if($filename != '.' && $filename != '..' && $filename != '.svn')
{
unlink($default_dir."/".$filename);
}
}
}
public function setMulti ($items , $expiration = 0)
{
//echo '*'.count($items).'*';
$keys = array_keys($items);
$result = array();
for($i =0; $i < count($keys); $i++)
{
$key = $keys[$i];
$value = $items[$key];
//echo $value;
self::set($key, $value);
}
return $value;
}
public function getMulti ( $keys , &$cas_tokens =null, $flags=null)
{
//echo '*'.count($keys).'*';
$result = array();
for($i =0; $i < count($keys); $i++)
{
$key = $keys[$i];
$value = self::get($key);
//echo $value;
if($value !== false)
{
$result[$key] = $value;
}
}
return $result;
}
public function delete ( $key , $expiration = 0)
{
$cache = FileCache::getInstance();
//echo $value;
$cache->delete($key);
}
}
Jump to Line
Something went wrong with that request. Please try again.