• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FileCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: blindClass

 public function blindClass()
 {
     opcache_reset();
     $loader = (require __ROOT__ . '/vendor/autoload.php');
     $loader->setUseIncludePath(true);
     $app = new \Group\App\App();
     $app->initSelf();
     $app->doBootstrap($loader);
     $app->registerServices();
     $app->singleton('container')->setAppPath(__ROOT__);
     $classMap = new Group\Common\ClassMap();
     $classes = $classMap->doSearch();
     \FileCache::set('services', $classes, $this->cacheDir);
     $this->addClass($classes, $this->server);
 }
开发者ID:fucongcong,项目名称:framework,代码行数:15,代码来源:RpcKernal.php


示例17: checkArgv

 /**
  * 检查输入的参数与命令
  *
  */
 protected function checkArgv()
 {
     $argv = $this->argv;
     if (!isset($argv[1])) {
         return;
     }
     $config = \Config::get("async::server");
     if (!isset($config[$argv[1]])) {
         return;
     }
     $log = isset($config[$argv[1]]['config']['log_file']) ? $config[$argv[1]]['config']['log_file'] : 'runtime/async/default.log';
     $log = explode("/", $log);
     \FileCache::set(array_pop($log), '', implode("/", $log) . "/");
     $server = new Server($config[$argv[1]], $argv[1]);
     die;
 }
开发者ID:fucongcong,项目名称:framework,代码行数:20,代码来源:Async.php


示例18: get

 public function get($key)
 {
     $full_path = "{$this->path}/{$key}";
     if (file_exists($full_path)) {
         $file = fopen($full_path, 'rb');
         flock($file, LOCK_SH);
         list($expiry_time, $data) = FileCache::parse(file_get_contents($full_path));
         fclose($file);
         if ($this->has_expired($expiry_time)) {
             return $this->refresh($key);
         } else {
             return $data;
         }
     } else {
         return $this->refresh($key);
     }
 }
开发者ID:myna,项目名称:myna-php,代码行数:17,代码来源:FileCache.php


示例19: __autoload

/**
 * Class autoloader
 *
 * Include classes automatically when they are instantiated.
 * @param string
 */
function __autoload($strClassName)
{
    $objCache = FileCache::getInstance('autoload');
    // Try to load the class name from the session cache
    if (!$GLOBALS['TL_CONFIG']['debugMode'] && isset($objCache->{$strClassName})) {
        if (@(include_once TL_ROOT . '/' . $objCache->{$strClassName})) {
            return;
            // The class could be loaded
        } else {
            unset($objCache->{$strClassName});
            // The class has been removed
        }
    }
    $strLibrary = TL_ROOT . '/system/libraries/' . $strClassName . '.php';
    // Check for libraries first
    if (file_exists($strLibrary)) {
        include_once $strLibrary;
        $objCache->{$strClassName} = 'system/libraries/' . $strClassName . '.php';
        return;
    }
    // Then check the modules folder
    foreach (scan(TL_ROOT . '/system/modules/') as $strFolder) {
        if (substr($strFolder, 0, 1) == '.') {
            continue;
        }
        $strModule = TL_ROOT . '/system/modules/' . $strFolder . '/' . $strClassName . '.php';
        if (file_exists($strModule)) {
            include_once $strModule;
            $objCache->{$strClassName} = 'system/modules/' . $strFolder . '/' . $strClassName . '.php';
            return;
        }
    }
    // HOOK: include Swift classes
    if (class_exists('Swift', false)) {
        Swift::autoload($strClassName);
        return;
    }
    // HOOK: include DOMPDF classes
    if (function_exists('DOMPDF_autoload')) {
        DOMPDF_autoload($strClassName);
        return;
    }
    trigger_error(sprintf('Could not load class %s', $strClassName), E_USER_ERROR);
}
开发者ID:jens-wetzel,项目名称:use2,代码行数:50,代码来源:functions.php


示例20: 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();
     }
 }
开发者ID:note4me,项目名称:AlfredWorkflow.com,代码行数:19,代码来源:stock.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP FileCtl类代码示例发布时间:2022-05-23
下一篇:
PHP FileBackendGroup类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap