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


PHP FileCache类代码示例

本文整理汇总了PHP中FileCache的典型用法代码示例。如果您正苦于以下问题:PHP FileCache类的具体用法?PHP FileCache怎么用?PHP FileCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FileCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSet_expire

 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);
 }
开发者ID:hidetobara,项目名称:voices,代码行数:7,代码来源:TestFileCache.php

示例2: execute

 public function execute($parameters, $db)
 {
     global $base;
     chdir($base);
     if (sizeof($parameters) == 0 || $parameters[0] == "") {
         CLI::out("Usage: |g|help <command>|n| To see a list of commands, use: |g|list", true);
     }
     $command = $parameters[0];
     switch ($command) {
         case "all":
             // Cleanup old sessions
             $db->execute("delete from zz_users_sessions where validTill < now()");
             $killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
             Storage::store("KillsLastHour", $killsLastHour);
             $db->execute("delete from zz_analytics where dttm < date_sub(now(), interval 24 hour)");
             $fc = new FileCache("{$base}/cache/queryCache/");
             $fc->cleanUp();
             break;
         case "killsLastHour":
             $killsLastHour = $db->queryField("select count(*) count from zz_killmails where insertTime > date_sub(now(), interval 1 hour)", "count");
             Storage::store("KillsLastHour", $killsLastHour);
             break;
         case "fileCacheClean":
             $fc = new FileCache();
             $fc->cleanUp();
             break;
     }
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:28,代码来源:cli_minutely.php

示例3: commentListGet

function commentListGet()
{
    $cacheFile = new FileCache();
    $cacheFile->load('commentlist.json');
    if ($cacheFile->needUpdate()) {
        return commentListGenerate();
    } else {
        return json_decode($cacheFile->read());
    }
}
开发者ID:laekov,项目名称:shiruku,代码行数:10,代码来源:comment.php

示例4: 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));
 }
开发者ID:0x20h,项目名称:phloppy,代码行数:10,代码来源:FileCacheTest.php

示例5: 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');
 }
开发者ID:hidetobara,项目名称:VolatileTwit,代码行数:13,代码来源:talk.php

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

示例7: __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;
 }
开发者ID:fucongcong,项目名称:framework,代码行数:27,代码来源:CronAdmin.php

示例8: execute

 public function execute($parameters, $db)
 {
     global $enableAnalyze;
     $actualKills = Storage::retrieve("ActualKillCount");
     $iteration = 0;
     while ($actualKills > 0) {
         $iteration++;
         $actualKills -= 1000000;
         if ($actualKills > 0 && Storage::retrieve("{$iteration}mAnnounced", null) == null) {
             Storage::store("{$iteration}mAnnounced", true);
             $message = "|g|Woohoo!|r| {$iteration} million kills surpassed!";
             Log::irc($message);
             Log::ircAdmin($message);
         }
     }
     $highKillID = $db->queryField("select max(killID) highKillID from zz_killmails", "highKillID");
     if ($highKillID > 2000000) {
         Storage::store("notRecentKillID", $highKillID - 2000000);
     }
     self::apiPercentage($db);
     $db->execute("delete from zz_api_log where requestTime < date_sub(now(), interval 2 hour)");
     //$db->execute("update zz_killmails set kill_json = '' where processed = 2 and killID < 0 and kill_json != ''");
     $db->execute("delete from zz_errors where date < date_sub(now(), interval 1 day)");
     $fileCache = new FileCache();
     $fileCache->cleanup();
     $tableQuery = $db->query("show tables");
     $tables = array();
     foreach ($tableQuery as $row) {
         foreach ($row as $column) {
             $tables[] = $column;
         }
     }
     if ($enableAnalyze) {
         $tableisgood = array("OK", "Table is already up to date", "The storage engine for the table doesn't support check");
         $count = 0;
         foreach ($tables as $table) {
             $count++;
             if (Util::isMaintenanceMode()) {
                 continue;
             }
             $result = $db->queryRow("analyze table {$table}");
             if (!in_array($result["Msg_text"], $tableisgood)) {
                 Log::ircAdmin("|r|Error analyzing table |g|{$table}|r|: " . $result["Msg_text"]);
             }
         }
     }
 }
开发者ID:Covert-Inferno,项目名称:zKillboard,代码行数:47,代码来源:cli_hourly.php

示例9: getCache

 /**
  * Ziskat instanci cache komponentu
  * @return FileCache
  */
 public static function getCache()
 {
     if (null === self::$cache) {
         self::$cache = new FileCache(_indexroot . 'data/tmp/cache');
         self::$cache->setVerifyBoundFiles(1 == _dev);
     }
     return self::$cache;
 }
开发者ID:sunlight-cms,项目名称:sunlight-cms-7,代码行数:12,代码来源:load.php

示例10: clear

 static function clear()
 {
     if (extension_loaded("memcached")) {
         $memcache = self::memcacheInit();
         $memcache->flush();
     } else {
         FileCache::clear();
     }
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:9,代码来源:SiteCache.php

示例11: getUnsortedTopData

 private static function getUnsortedTopData($manual)
 {
     $allowHidden = util_isModerator(PRIV_VIEW_HIDDEN);
     $data = FileCache::getTop($manual, $allowHidden);
     if (!$data) {
         $data = TopEntry::loadUnsortedTopData($manual);
         FileCache::putTop($data, $manual, $allowHidden);
     }
     return $data;
 }
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:10,代码来源:TopEntry.php

示例12: 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);
 }
开发者ID:fucongcong,项目名称:framework,代码行数:10,代码来源:SqlMigrateCommand.php

示例13: getCacher

	/**
	 * 获取缓存类
	 * @param string $type
	 * @return FileCache | RedisCache
	 */
	public static function getCacher ($type = '', $model = '') {
		$type or $type = C('DEFAULT_CACHER');
		if (!in_array($type, array('redis', 'file', 'remote'))) {
			$type = 'redis';
		}
		//如果不是正式服务上,不是用redis缓存
		if (false == SuiShiPHPConfig::get('PUBLIC_SERVICE') && 'redis' == $type) {
			$type = 'file';
		}
		$cacheId = $type.$model;
		if (isset(self::$CACHER[$cacheId])) {
			return self::$CACHER[$cacheId];
		}

		switch ($type) {
			case 'file':
				if (!class_exists("FileCache")) {
					include_once SUISHI_PHP_PATH . '/Cache/FileCache.class.php';
				}
				$c = new FileCache(C('RUN_SHELL'));
				$c->setModel($model);
				$c->setPath(SuiShiPHPConfig::getFileCacheDir());
				self::$CACHER[$cacheId] = $c;
				break;
			case 'remote':
				if (!class_exists("FileCache")) {
					include_once SUISHI_PHP_PATH . '/Cache/RemoteCacher.class.php';
				}
				$c = new RemoteCacher(C('REMOTE_CACHE_HOST'), C('REMOTE_CACHE_PORT'), 'weixinapp');
				self::$CACHER[$cacheId] = $c;
				break;
			default:
				if (!class_exists("RedisCache")) {
					include_once SUISHI_PHP_PATH . '/Cache/RedisCache.class.php';
				}
				$c = new RedisCache(SuiShiPHPConfig::get('REDIS_HOST'), SuiShiPHPConfig::get('REDIS_PORT'));
				self::$CACHER[$cacheId] = $c;
				break;
		}
		return self::$CACHER[$cacheId];
	}
开发者ID:neil-chen,项目名称:NeilChen,代码行数:46,代码来源:Factory.class.php

示例14: 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();
 }
开发者ID:fucongcong,项目名称:framework,代码行数:12,代码来源:SqlRollBackCommand.php

示例15: __construct

 public function __construct($search_paths = array())
 {
     $this->paths = $search_paths;
     $this->modules = $this->getModules();
     if (FileCache::is_cached('modules_info', 180)) {
         // cache expire after 3 mins
         $this->modules_info = FileCache::fetch('modules_info', null, 180);
     } else {
         $this->modules_info = array();
         $this->getCNModulesInfo();
         FileCache::store('modules_info', $this->modules_info, 180);
     }
 }
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:13,代码来源:CNModulesInfo.php


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