src/Biz/System/Service/Impl/CacheServiceImpl.php
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Biz\System\Service\Impl;
use Biz\BaseService;
use Biz\System\Service\CacheService;
class CacheServiceImpl extends BaseService implements CacheService
{
public function get($name)
{
$datas = $this->gets(array($name));
if (empty($datas)) {
return null;
}
return reset($datas);
}
public function gets(array $names)
{
$this->garbageCollection();
$names = array_filter($names);
if (empty($names)) {
return array();
}
$datas = array();
$caches = $this->getCacheDao()->findByNames($names);
$now = time();
foreach ($caches as $cache) {
if ($cache['expiredTime'] > 0 && $cache['expiredTime'] < $now) {
continue;
}
$datas[$cache['name']] = $cache['serialized'] ? unserialize($cache['data']) : $cache['data'];
}
return $datas;
}
public function set($name, $data, $expiredTime = 0)
{
$serialized = is_string($data) ? 0 : 1;
$cache = array(
'name' => $name,
'data' => $serialized ? serialize($data) : $data,
'serialized' => $serialized,
'expiredTime' => $expiredTime,
'createdTime' => time(),
);
$cached = $this->getCacheDao()->findByNames(array($name));
if (empty($cached)) {
return $this->getCacheDao()->create($cache);
} else {
return $this->getCacheDao()->updateByName($name, $cache);
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。