本文整理汇总了PHP中FileCache::get方法的典型用法代码示例。如果您正苦于以下问题:PHP FileCache::get方法的具体用法?PHP FileCache::get怎么用?PHP FileCache::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileCache
的用法示例。
在下文中一共展示了FileCache::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExpire
public function testExpire()
{
$key = uniqid();
$c = new FileCache($this->file);
$this->assertTrue($c->set($key, ['bar' => ['baz']], 1));
$this->assertEquals(['bar' => ['baz']], $c->get($key));
$this->assertTrue($c->expires($key) <= time() + 1);
sleep(2);
$this->assertNull($c->get($key));
}
示例2: FileCache
function testSet_expire()
{
$cache = new FileCache();
$cache->set($this->name, $this->data, new DateTime('-1 day'));
$result = $cache->get($this->name);
$this->assertSame(null, $result);
}
示例3: __construct
public function __construct()
{
$http = new swoole_http_server('127.0.0.1', '9999');
$http->set(array('reactor_num' => 1, 'worker_num' => 2, 'backlog' => 128, 'max_request' => 500, 'heartbeat_idle_time' => 30, 'heartbeat_check_interval' => 10, 'dispatch_mode' => 3));
$http->on('request', function ($request, $response) {
$request->get = isset($request->get) ? $request->get : [];
$request->post = isset($request->post) ? $request->post : [];
$request->cookie = isset($request->cookie) ? $request->cookie : [];
$request->files = isset($request->files) ? $request->files : [];
$request->server = isset($request->server) ? $request->server : [];
if ($request->server['request_uri'] == '/favicon.ico') {
$response->end();
return;
}
$cache_dir = \Config::get('cron::cache_dir') ?: 'runtime/cron';
$pid = \FileCache::get('pid', $cache_dir);
$work_ids = \FileCache::get('work_ids', $cache_dir);
ob_start();
require __DIR__ . "/View/console.php";
$output = ob_get_contents();
ob_end_clean();
$response->status(200);
$response->end($output);
return;
});
$this->http = $http;
}
示例4: get
static function get($key)
{
if (extension_loaded("memcached")) {
$memcache = self::memcacheInit();
return $memcache->get($key);
} else {
return FileCache::get($key);
}
}
示例5: init
public function init()
{
$sqlDir = __ROOT__ . "app/sql/";
$lock = \FileCache::isExist("sql.lock", $sqlDir);
if ($lock) {
$this->fileList = \FileCache::get("sql.lock", $sqlDir);
}
$this->ListSql($sqlDir);
\FileCache::set("sql.lock", $this->fileList, $sqlDir);
}
示例6: init
public function init()
{
$sqlDir = __ROOT__ . "app/sql/";
$lock = \FileCache::isExist("sql.lock", $sqlDir);
if ($lock) {
$this->fileList = \FileCache::get("sql.lock", $sqlDir);
}
$this->ListSql($sqlDir);
//清除lock
$clean = new SqlCleanCommand();
$clean->init();
}
示例7: stop
/**
* 停止队列服务
*
*/
public function stop()
{
$pid = $this->getPid();
if (!empty($pid) && $pid) {
if (swoole_process::kill($pid, 0)) {
//杀掉worker进程
foreach (\FileCache::get('work_ids', $this->logDir . "/") as $work_id) {
swoole_process::kill($work_id, SIGTERM);
}
}
}
}
示例8: handle
function handle()
{
$cache = new FileCache();
$info = $cache->get(self::CACHE_KEY);
if (!is_array($info)) {
$shokos = new VolatileTwitShokos();
$info = $shokos->bestTalkInfo();
$cache->set(self::CACHE_KEY, $info, new DateTime("+30 min"));
}
$this->assign('rate', $info['rate']);
$this->assign('text', $info['text']);
$this->assign('status', 'ok');
}
示例9: run
function run()
{
$cache = new FileCache();
$box = $cache->get(self::TWITTER_CRAWL_KEY);
if (!is_array($box)) {
$box = array();
}
$api = new TwitterApi(HIDETOBARA_OAUTH_KEY, HIDETOBARA_OAUTH_SECRET);
$a = $api->getHomeTimeline($box);
$storage = new TwitterStorage();
$storage->retrieveStatus($a);
$storage->saveStatusByDate(LOG_DIR . "status/");
$box = $storage->updateUserCache($box);
$cache->set(self::TWITTER_CRAWL_KEY, $box);
}
示例10: search
function search()
{
$cacheData = FileCache::get('__cache__' . $this->keyword);
if (!$cacheData) {
$url = $this->queryUrl . urlencode($this->keyword);
$request_result = $this->request($url);
$json = json_decode($request_result);
$searchData = $json->data;
if (count($searchData) > 0) {
FileCache::set('__cache__' . $this->keyword, $searchData, 24 * 60 * 60);
}
} else {
$searchData = $cacheData;
}
if (count($searchData) > 0) {
$codeArray = array();
foreach ($searchData as $value) {
$d = explode('~', $value);
if (preg_match('/(\\..*)$/', $d[1], $re)) {
$d[1] = str_replace($re[1], "", $d[1]);
}
if ($d[0] == 'us') {
$d[1] = strtoupper($d[1]);
}
$dCode = $d[0] . $d[1];
if ($d[0] == 'hk') {
$dCode = 'r_' . $dCode;
}
if ($d[0] == 'jj') {
$dCode = 's_' . $dCode;
}
array_push($codeArray, $dCode);
}
$qt = new StockQt();
$qt->fetchQt(implode(',', $codeArray));
foreach ($searchData as $key => $value) {
$stock = new Stock($value, $qt);
$this->result($key, $stock->getLink(), $stock->getTitle(), $stock->getSubTitle(), null);
}
} else {
$this->lastPlaceholder();
}
}
示例11: search
function search()
{
$qtData = FileCache::get($this->keyword);
if (!$qtData) {
$url = $this->queryUrl . urlencode($this->keyword);
$request_result = $this->request($url);
$json = json_decode($request_result);
$qtData = $json->data;
}
if (count($qtData) > 0) {
FileCache::set($this->keyword, $qtData);
foreach ($qtData as $key => $value) {
$stock = new Stock($value);
$this->result($key, $stock->getLink(), $stock->getTitle(), $stock->getSubTitle(), null);
}
} else {
$this->lastPlaceholder();
}
}
示例12: content_key_for_mtime_key
private function content_key_for_mtime_key($key, $work_units)
{
if (!(defined('SACY_USE_CONTENT_BASED_CACHE') && SACY_USE_CONTENT_BASED_CACHE)) {
return $key;
}
$cache_key = 'ck-for-mkey-' . $key;
$ck = $this->fragment_cache->get($cache_key);
if (!$ck) {
$ck = "";
foreach ($work_units as $f) {
$ck = md5($ck . md5_file($f['file']));
foreach ($f['additional_files'] as $af) {
$ck = md5($ck . md5_file($af));
}
}
$ck = "{$ck}-content";
$this->fragment_cache->set($cache_key, $ck);
}
return $ck;
}
示例13: util_assertNotMirror
<?php
require_once "../../phplib/util.php";
util_assertNotMirror();
util_assertNotLoggedIn();
$loginType = util_getRequestParameter('loginType');
$nickOrEmail = util_getRequestParameter('nickOrEmail');
$password = util_getRequestParameter('password');
$nick = util_getRequestParameter('nick');
$randString = util_getRequestParameter('randString');
$data = FileCache::get($randString);
if (!$data) {
FlashMessage::add('A apărut o eroare la autentificare. Vă rugăm încercați din nou.');
} else {
if ($loginType == 0) {
$user = Model::factory('User')->where('password', md5($password))->where_raw("(email = '{$nickOrEmail}' or nick = '{$nickOrEmail}')")->find_one();
if (!$user) {
FlashMessage::add('Numele de utilizator sau parola sunt incorecte.');
} else {
if ($user->identity) {
FlashMessage::add('Acest utilizator a fost deja revendicat de un alt OpenID.');
} else {
session_login($user, $data);
}
}
} else {
$openidNick = $loginType == 1 ? $data['fullname'] : ($loginType == 2 ? $data['nickname'] : $nick);
$user = User::get_by_nick($openidNick);
if ($user) {
FlashMessage::add('Acest nume de utilizator este deja luat.');
} else {
示例14: util_assertNotMirror
<?php
require_once "../../phplib/util.php";
util_assertNotMirror();
util_assertNotLoggedIn();
$token = util_getRequestParameter('token');
$identity = util_getRequestParameter('identity');
$pt = PasswordToken::get_by_token($token);
$data = FileCache::get($identity);
if (!$pt) {
FlashMessage::add('Ați introdus un cod de recuperare incorect.');
} else {
if ($pt->createDate < time() - 24 * 3600) {
FlashMessage::add('Codul de recuperare introdus a expirat.');
} else {
if (!$data) {
FlashMessage::add('Ați introdus o identitate incorectă.');
} else {
$user = User::get_by_id($pt->userId);
if (!$user) {
FlashMessage::add('Ați introdus un cod de recuperare incorect.');
} else {
if ($user->identity) {
FlashMessage::add('Acest cont a fost deja revendicat de o identitate OpenID.');
} else {
FlashMessage::add('Contul dumneavoastră a fost recuperat și unificat cu identitatea OpenID.', 'info');
session_login($user, $data);
}
}
}
}
示例15: getRoutingConfig
private function getRoutingConfig()
{
$file = 'route/routing.php';
if ($this->container->getEnvironment() == "prod") {
if (\FileCache::isExist($file)) {
return \FileCache::get($file);
}
}
$sources = \Config::get('routing::source');
$routings = [];
foreach ($sources as $source) {
$routing = (include_once "src/{$source}/routing.php");
if ($routing) {
$routings = array_merge($routings, $routing);
}
}
\FileCache::set($file, $routings);
return $routings;
}