PSR规范调整

This commit is contained in:
thinkphp
2015-10-04 13:05:15 +08:00
parent 1cfb3704c6
commit 27e724bb3c
135 changed files with 9426 additions and 11556 deletions

View File

@@ -15,12 +15,13 @@ namespace think\cache\driver;
* Eaccelerator缓存驱动
* @author liu21st <liu21st@gmail.com>
*/
class Eaccelerator {
class Eaccelerator
{
protected $options = [
'prefix' => '',
'expire' => 0,
'length' => 0,
protected $options = [
'prefix' => '',
'expire' => 0,
'length' => 0,
];
/**
@@ -28,9 +29,10 @@ class Eaccelerator {
* @param array $options 缓存参数
* @access public
*/
public function __construct($options=[]) {
if(!empty($options)) {
$this->options = array_merge($this->options,$options);
public function __construct($options = [])
{
if (!empty($options)) {
$this->options = array_merge($this->options, $options);
}
}
@@ -40,9 +42,10 @@ class Eaccelerator {
* @param string $name 缓存变量名
* @return mixed
*/
public function get($name) {
return eaccelerator_get($this->options['prefix'].$name);
}
public function get($name)
{
return eaccelerator_get($this->options['prefix'] . $name);
}
/**
* 写入缓存
@@ -52,23 +55,27 @@ class Eaccelerator {
* @param integer $expire 有效时间(秒)
* @return boolen
*/
public function set($name, $value, $expire = null) {
if(is_null($expire)) {
$expire = $this->options['expire'];
public function set($name, $value, $expire = null)
{
if (is_null($expire)) {
$expire = $this->options['expire'];
}
$name = $this->options['prefix'].$name;
$name = $this->options['prefix'] . $name;
eaccelerator_lock($name);
if(eaccelerator_put($name, $value, $expire)) {
if($this->options['length']>0) {
if (eaccelerator_put($name, $value, $expire)) {
if ($this->options['length'] > 0) {
// 记录缓存队列
$queue = eaccelerator_get('__info__');
if(!$queue) {
$queue = [];
$queue = eaccelerator_get('__info__');
if (!$queue) {
$queue = [];
}
if(false===array_search($name, $queue)) array_push($queue,$name);
if(count($queue) > $this->options['length']) {
if (false === array_search($name, $queue)) {
array_push($queue, $name);
}
if (count($queue) > $this->options['length']) {
// 出列
$key = array_shift($queue);
$key = array_shift($queue);
// 删除缓存
eaccelerator_rm($key);
}
@@ -77,8 +84,7 @@ class Eaccelerator {
return true;
}
return false;
}
}
/**
* 删除缓存
@@ -86,16 +92,18 @@ class Eaccelerator {
* @param string $name 缓存变量名
* @return boolen
*/
public function rm($name) {
return eaccelerator_rm($this->options['prefix'].$name);
}
public function rm($name)
{
return eaccelerator_rm($this->options['prefix'] . $name);
}
/**
* 清除缓存
* @access public
* @return boolen
*/
public function clear() {
return ;
public function clear()
{
return;
}
}