当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::get方法代码示例

本文整理汇总了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;
 }
开发者ID:GameCrusherTechnology,项目名称:HeroTowerServer,代码行数:7,代码来源:MemLocker.class.php

示例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());
 }
开发者ID:phossa,项目名称:phossa-config,代码行数:13,代码来源:CacheTest.php

示例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;
 }
开发者ID:baki250,项目名称:angular-io-app,代码行数:18,代码来源:api.test.php

示例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;
 }
开发者ID:rotoballer,项目名称:emily,代码行数:9,代码来源:gantrycache.class.php

示例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'));
 }
开发者ID:Selwyn-b,项目名称:elefant,代码行数:9,代码来源:CacheTest.php

示例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);
 }
开发者ID:DerpMarceline,项目名称:widget,代码行数:15,代码来源:Curse.php

示例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'];
     });
 }
开发者ID:emilymwang8,项目名称:ajk-broker,代码行数:15,代码来源:Js.php

示例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'];
     });
 }
开发者ID:emilymwang8,项目名称:ajk-broker,代码行数:15,代码来源:Color.php

示例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;
 }
开发者ID:stoneworld,项目名称:wechat,代码行数:18,代码来源:AccessToken.php

示例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;
     }
 }
开发者ID:sunblade,项目名称:core,代码行数:19,代码来源:watcher.php

示例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());
 }
开发者ID:gjerokrsteski,项目名称:php-dba-cache,代码行数:20,代码来源:Sweep.php

示例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'];
     });
 }
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:18,代码来源:Color.php

示例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'];
     });
 }
开发者ID:emilymwang8,项目名称:ajk-broker,代码行数:19,代码来源:AccessToken.php

示例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;
 }
开发者ID:AndrOrt,项目名称:Services_Openstreetmap,代码行数:33,代码来源:HTTPCached.php

示例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);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:20,代码来源:watcher.php


注:本文中的Cache::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。