本文整理汇总了PHP中Cache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::get方法的具体用法?PHP Cache::get怎么用?PHP Cache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isLocked
public function isLocked($key)
{
if ($this->cache->get($key) === false) {
return false;
}
return true;
}
示例2: testSave
/**
* @covers Phossa\Config\Env\Environment::save()
* @covers Phossa\Config\Env\Environment::get()
* @covers Phossa\Config\Env\Environment::clear()
*/
public function testSave()
{
$data = ['db' => ['dsn' => 'bingo']];
$this->object->save($data);
$this->assertEquals($data, $this->object->get());
$this->object->clear();
$this->assertFalse($this->object->get());
}
示例3: testCache
/**
* cache test call
*
* @param string $input
* @return bool
*
* @url GET cache
* @access public
*/
function testCache($input = '')
{
$redis = new Cache('test', 'redis', array());
$r[] = $redis->get('key');
$r[] = $redis->set('key', 'value');
$r[] = $redis->get('key');
$r[] = $redis->del('key');
return $r;
}
示例4: get
public function get($groupName, $identifier, $function = null, $arguments = array())
{
$ret = $this->cache->get($groupName, $identifier, $this->lifetime);
if ($ret == false && $function != null) {
$ret = call_user_func_array($function, $arguments);
$this->cache->set($groupName, $identifier, $ret);
}
return $ret;
}
示例5: Cache
function test_timeout()
{
$c = new Cache();
// test cache expiry
$c->set('bar', 'asdf', 0, 1);
$this->assertEquals('asdf', $c->get('bar'));
sleep(2);
$this->assertFalse($c->get('bar'));
}
示例6: project
/**
* Take a project key and return the properties
*
* @param string $identifier
* @return array
*/
public function project($identifier)
{
if (!$this->cache->has($identifier)) {
$html = $this->fetch($identifier);
$project = $this->parse($html);
$this->cache->set($identifier, $project, $this->expiry);
}
return $this->cache->get($identifier);
}
示例7: getTicket
/**
* 获取jsticket
*
* @return string
*/
public function getTicket()
{
$key = 'overtrue.wechat.jsapi_ticket' . $this->appId;
return $this->cache->get($key, function ($key) {
$http = new Http(new AccessToken($this->appId, $this->appSecret));
$result = $http->get(self::API_TICKET);
$this->cache->set($key, $result['ticket'], $result['expires_in']);
return $result['ticket'];
});
}
示例8: lists
/**
* 获取颜色列表
*
* @return array
*/
public function lists()
{
$key = 'overtrue.wechat.colors';
return $this->cache->get($key, function ($key) {
$result = $this->http->get(self::API_LIST);
$this->cache->set($key, $result['colors'], 86400);
// 1 day
return $result['colors'];
});
}
示例9: getToken
/**
* 获取Token
*
* @param bool $forceRefresh
*
* @return string
*/
public function getToken($forceRefresh = false)
{
$cacheKey = $this->cacheKey;
$cached = $this->cache->get($cacheKey);
if ($forceRefresh || !$cached) {
$token = $this->getTokenFromServer();
$this->cache->set($cacheKey, $token['access_token'], $token['expires_in'] - 800);
return $token['access_token'];
}
return $cached;
}
示例10: checkUpdate
/**
* check $path for updates and update if needed
*
* @param string $path
* @param array $cachedEntry
* @return boolean true if path was updated
*/
public function checkUpdate($path, $cachedEntry = null)
{
if (is_null($cachedEntry)) {
$cachedEntry = $this->cache->get($path);
}
if ($this->needsUpdate($path, $cachedEntry)) {
$this->update($path, $cachedEntry);
return true;
} else {
return false;
}
}
示例11: process
/**
* Internal cleaning process.
*
* @param boolean $cleanAll
*
* @return void
*/
protected function process($cleanAll = true)
{
$key = dba_firstkey($this->cache->getDba());
while ($key !== false && $key !== null) {
if (true === $cleanAll) {
$this->cache->delete($key);
} else {
$this->cache->get($key);
}
$key = dba_nextkey($this->cache->getDba());
}
dba_optimize($this->cache->getDba());
}
示例12: lists
/**
* 获取颜色列表
*
* @return array
*/
public function lists()
{
$key = 'overtrue.wechat.colors';
// for php 5.3
$http = $this->http;
$cache = $this->cache;
return $this->cache->get($key, function ($key) use($http, $cache) {
$result = $http->get(self::API_LIST);
$cache->set($key, $result['colors'], 86400);
// 1 day
return $result['colors'];
});
}
示例13: getToken
/**
* 获取Token
*
* @return string
*/
public function getToken()
{
if ($this->token) {
return $this->token;
}
$thisObj = $this;
return $this->cache->get($this->cacheKey, function () use($thisObj) {
$params = array('appid' => $thisObj->appId, 'secret' => $thisObj->appSecret, 'grant_type' => 'client_credential');
$http = new Http();
$token = $http->get($thisObj::API_TOKEN_GET, $params);
$thisObj->cache->set($thisObj->cacheKey, $token['access_token'], $token['expires_in']);
return $thisObj->token = $token['access_token'];
});
}
示例14: getResponse
/**
* Send request to OSM server and return the response.
*
* @param string $url URL
* @param string $method GET (default)/POST/PUT
* @param string $user user (optional for read-only actions)
* @param string $password password (optional for read-only actions)
* @param string $body body (optional)
* @param array $post_data (optional)
* @param array $headers (optional)
*
* @access public
* @return HTTP_Request2_Response
* @todo Consider just returning the content?
* @throws Services_OpenStreetMap_Exception If something unexpected has
* happened while conversing with
* the server.
*/
public function getResponse($url, $method = HTTP_Request2::METHOD_GET, $user = null, $password = null, $body = null, array $post_data = null, array $headers = null)
{
$arguments = array($url, $method, $user, $password, $body, implode(":", (array) $post_data), implode(":", (array) $headers));
$id = md5(implode(":", $arguments));
$data = $this->cache->get($id);
if ($data) {
$response = new HTTP_Request2_Response();
$response->setStatus(200);
$response->setBody($data);
return $response;
}
$response = parent::getResponse($url, $method, $user, $password, $body, $post_data, $headers);
$this->cache->save($id, $response->getBody());
return $response;
}
示例15: checkUpdate
/**
* check $path for updates
*
* @param string $path
*/
public function checkUpdate($path)
{
$cachedEntry = $this->cache->get($path);
if ($this->storage->hasUpdated($path, $cachedEntry['mtime'])) {
if ($this->storage->is_dir($path)) {
$this->scanner->scan($path, Scanner::SCAN_SHALLOW);
} else {
$this->scanner->scanFile($path);
}
if ($cachedEntry['mimetype'] === 'httpd/unix-directory') {
$this->cleanFolder($path);
}
$this->cache->correctFolderSize($path);
}
}