<?php
/**
* SAE KV-STORAGE
*给出资源,计算md5,载入db
*/
class storage
{
private static $kv;
function __construct()
{
self::$kv = new SaeKV();
self::$kv->init();
}
public function get($key)
{
return self::$kv->get($key);
}
public function set($key,$value)
{
return self::$kv->set($key,$value);
}
public function del($key)
{
return self::$kv->delete($key);
}
public function mget($arr)
{
return self::$kv->mget($arr);
}
public function pkrget($key,$num=3)
{
return self::$kv->pkrget($key,$num);
}
///下面可供使用
public function push($bindata)
{
$gz=gzcompress($bindata);
if(strlen($gz)>4194304) return false;
$key=md5($gz);
return $this->set($key,$gz);
}
public function dump($key)
{
$gz=$this->get($key);
$bindata=$gz?gzuncompress($gz):null;
return $bindata;
}
}
//using
$db=new storage();
转载于:https://my.oschina.net/suconghou/blog/195978