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


PHP CacheCore类代码示例

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


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

示例1: chobits_getcachevars

 public static function chobits_getcachevars($data, $type = 'VAR')
 {
     $evaluate = '';
     foreach ($data as $key => $val) {
         if (is_array($val)) {
             $evaluate .= "\${$key} = " . CacheCore::chobits_arrayeval($val) . ";\n";
         } else {
             $val = addcslashes($val, '\'\\');
             $evaluate .= $type == 'VAR' ? "\${$key} = '{$val}';\n" : "define('" . strtoupper($key) . "', '{$val}');\n";
         }
     }
     return $evaluate;
 }
开发者ID:royburns,项目名称:project-nowhere,代码行数:13,代码来源:CacheCore.php

示例2: cache_instance_profile_credentials

 /**
  * Fetches and caches EC2 instance profile credentials. This is meant to be used by the constructor, and is not to
  * be manually invoked.
  *
  * @param CacheCore $cache (Required) The a reference to the cache object that is being used to handle the caching.
  * @param array $options (Required) The options that were passed into the constructor.
  * @return mixed The data to be cached, or NULL.
  */
 public function cache_instance_profile_credentials($cache, $options)
 {
     $instance_profile_url = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/';
     $connect_timeout = isset($options['instance_profile_timeout']) ? $options['instance_profile_timeout'] : 2;
     try {
         // Make a call to the EC2 Metadata Service to find the available instance profile
         $request = new RequestCore($instance_profile_url);
         $request->set_curlopts(array(CURLOPT_CONNECTTIMEOUT => $connect_timeout));
         $response = $request->send_request(true);
         if ($response->isOK()) {
             // Get the instance profile name
             $profile = (string) $response->body;
             // Make a call to the EC2 Metadata Service to get the instance profile credentials
             $request = new RequestCore($instance_profile_url . $profile);
             $request->set_curlopts(array(CURLOPT_CONNECTTIMEOUT => $connect_timeout));
             $response = $request->send_request(true);
             if ($response->isOK()) {
                 // Get the credentials
                 $credentials = json_decode($response->body, true);
                 if ($credentials['Code'] === 'Success') {
                     // Determine the expiration time
                     $expiration_time = strtotime((string) $credentials['Expiration']);
                     $expiration_duration = round(($expiration_time - time()) * 0.85);
                     $cache->expire_in($expiration_duration);
                     // Return the credential information
                     return array('key' => $credentials['AccessKeyId'], 'secret' => $credentials['SecretAccessKey'], 'token' => $credentials['Token'], 'expires' => $credentials['Expiration']);
                 }
             }
         }
     } catch (cURL_Exception $e) {
         // The EC2 Metadata Service does not exist or had timed out.
         // An exception will be thrown on the next line.
     }
     // @codeCoverageIgnoreStart
     throw new CFCredentials_Exception('No credentials were provided. The SDK attempted to retrieve Instance ' . 'Profile credentials from the EC2 Instance Metadata Service, but failed to do so. Instance profile ' . 'credentials are only accessible on EC2 instances configured with a specific IAM role.');
     // @codeCoverageIgnoreEnd
 }
开发者ID:platonicsolution,项目名称:local-server,代码行数:45,代码来源:sdk.class.php

示例3: cache_sts_credentials

 /**
  * Fetches and caches STS credentials. This is meant to be used by the constructor, and is not to be
  * manually invoked.
  *
  * @param CacheCore $cache (Required) The a reference to the cache object that is being used to handle the caching.
  * @param array $options (Required) The options that were passed into the constructor.
  * @return mixed The data to be cached, or NULL.
  */
 public function cache_sts_credentials($cache, $options)
 {
     $token = new AmazonSTS($options);
     $response = $token->get_session_token();
     if ($response->isOK()) {
         // Update the expiration
         $expiration_time = strtotime((string) $response->body->GetSessionTokenResult->Credentials->Expiration);
         $expiration_duration = round(($expiration_time - time()) * 0.85);
         $cache->expire_in($expiration_duration);
         // Return the important data
         return array('key' => (string) $response->body->GetSessionTokenResult->Credentials->AccessKeyId, 'secret' => (string) $response->body->GetSessionTokenResult->Credentials->SecretAccessKey, 'token' => (string) $response->body->GetSessionTokenResult->Credentials->SessionToken, 'expires' => (string) $response->body->GetSessionTokenResult->Credentials->Expiration);
     }
     return null;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:22,代码来源:sdk.class.php

示例4: UpdateSettingsCache

 public static function UpdateSettingsCache()
 {
     global $db, $nw_uid, $tablepre, $timestamp, $adminid, $basic_settings, $webservice_settings;
     $cur_settings = self::FetchSettings();
     foreach ($cur_settings as $key => $value) {
         $data['nowhere_settings'][$key] = $value;
     }
     CacheCore::chobits_writetocache('nowhere_settings', '', CacheCore::chobits_getcachevars($data), '', 'cache');
 }
开发者ID:royburns,项目名称:project-nowhere,代码行数:9,代码来源:NowhereCore.php

示例5: __construct

 /**
  * Constructs a new instance of this class.
  *
  * @param string $name (Required) A name to uniquely identify the cache object.
  * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL.
  * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0.
  * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true.
  * @return object Reference to the cache object.
  */
 public function __construct($name, $location = null, $expires = 0, $gzip = true)
 {
     parent::__construct($name, null, $expires, $gzip);
     $this->id = $this->name;
     // Prefer Memcached over Memcache.
     if (class_exists('Memcached')) {
         $this->memcache = new Memcached();
         $this->is_memcached = true;
     } elseif (class_exists('Memcache')) {
         $this->memcache = new Memcache();
     } else {
         return false;
     }
     // Enable compression, if available
     if ($this->gzip) {
         if ($this->is_memcached) {
             $this->memcache->setOption(Memcached::OPT_COMPRESSION, true);
         } else {
             $this->gzip = MEMCACHE_COMPRESSED;
         }
     }
     // Process Memcached servers.
     if (isset($location) && sizeof($location) > 0) {
         foreach ($location as $loc) {
             if (isset($loc['port']) && !empty($loc['port'])) {
                 $this->memcache->addServer($loc['host'], $loc['port']);
             } else {
                 $this->memcache->addServer($loc['host'], 11211);
             }
         }
     }
     return $this;
 }
开发者ID:anil-kodali,项目名称:aws-sdk-for-php,代码行数:42,代码来源:cachemc.class.php

示例6: getInstance

 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         $caching_system = _PS_CACHING_SYSTEM_;
         self::$_instance = new $caching_system();
     }
     return self::$_instance;
 }
开发者ID:greench,项目名称:prestashop,代码行数:8,代码来源:Cache.php

示例7: __construct

 /**
  * Method: __construct()
  * 	The constructor
  * 
  * Access:
  * 	public
  * 
  * Parameters:
  * 	name - _string_ (Required) A name to uniquely identify the cache object.
  * 	location - _string_ (Required) The location to store the cache object in. This may vary by cache method.
  * 	expires - _integer_ (Required) The number of seconds until a cache object is considered stale.
  * 
  * Returns:
  * 	_object_ Reference to the cache object.
  * 
  * See Also:
  * 	Example Usage - http://tarzan-aws.com/docs/examples/cachecore/cache.phps
  */
 public function __construct($name, $location, $expires)
 {
     parent::__construct($name, null, $expires);
     $this->id = $this->name;
     $this->memcache = new Memcache();
     if (extension_loaded('zlib')) {
         $this->compressed = MEMCACHE_COMPRESSED;
     }
     foreach ($location as $loc) {
         $this->memcache->addServer($loc['host'], $loc['port']);
     }
 }
开发者ID:jpadilla,项目名称:codeigniter-s3-swfupload,代码行数:30,代码来源:_cachemc.class.php

示例8: __construct

 /**
  * Method: __construct()
  * 	The constructor
  *
  * Access:
  * 	public
  *
  * Parameters:
  * 	name - _string_ (Required) A name to uniquely identify the cache object.
  * 	location - _string_ (Required) The location to store the cache object in. This may vary by cache method.
  * 	expires - _integer_ (Required) The number of seconds until a cache object is considered stale.
  * 	gzip - _boolean_ (Optional) Whether data should be gzipped before being stored. Defaults to true.
  *
  * Returns:
  * 	_object_ Reference to the cache object.
  */
 public function __construct($name, $location, $expires, $gzip = true)
 {
     parent::__construct($name, null, $expires, $gzip);
     $this->id = $this->name;
     $this->memcache = new Memcache();
     if ($this->gzip) {
         $this->gzip = MEMCACHE_COMPRESSED;
     }
     if (isset($location) && sizeof($location) > 0) {
         foreach ($location as $loc) {
             if (isset($loc['port']) && !empty($loc['port'])) {
                 $this->memcache->addServer($loc['host'], $loc['port']);
             } else {
                 $this->memcache->addServer($loc['host']);
             }
         }
     }
     return;
 }
开发者ID:Alenpiera,项目名称:streeme,代码行数:35,代码来源:cachemc.class.php

示例9: __construct

 /**
  * Constructs a new instance of this class.
  *
  * Tested with [MySQL 5.0.x](http://mysql.com), [PostgreSQL](http://postgresql.com), and
  * [SQLite 3.x](http://sqlite.org). SQLite 2.x is assumed to work. No other PDO-supported databases have
  * been tested (e.g. Oracle, Microsoft SQL Server, IBM DB2, ODBC, Sybase, Firebird). Feel free to send
  * patches for additional database support.
  *
  * See <http://php.net/pdo> for more information.
  *
  * @param string $name (Required) A name to uniquely identify the cache object.
  * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL.
  * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0.
  * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true.
  * @return object Reference to the cache object.
  */
 public function __construct($name, $location = null, $expires = 0, $gzip = true)
 {
     // Make sure the name is no longer than 40 characters.
     $name = sha1($name);
     // Call parent constructor and set id.
     parent::__construct($name, $location, $expires, $gzip);
     $this->id = $this->name;
     $options = array();
     // Check if the location contains :// (e.g. mysql://user:pass@hostname:port/table)
     if (stripos($location, '://') === false) {
         // No? Just pass it through.
         $this->dsn = parse_url($location);
         $this->dsn_string = $location;
     } else {
         // Yes? Parse and set the DSN
         $this->dsn = parse_url($location);
         $this->dsn_string = $this->dsn['scheme'] . ':host=' . $this->dsn['host'] . (isset($this->dsn['port']) ? ';port=' . $this->dsn['port'] : '') . ';dbname=' . substr($this->dsn['path'], 1);
     }
     // Make sure that user/pass are defined.
     $user = isset($this->dsn['user']) ? $this->dsn['user'] : null;
     $pass = isset($this->dsn['pass']) ? $this->dsn['pass'] : null;
     // Set persistence for databases that support it.
     switch ($this->dsn['scheme']) {
         case 'mysql':
             // MySQL
         // MySQL
         case 'pgsql':
             // PostgreSQL
             $options[PDO::ATTR_PERSISTENT] = true;
             break;
     }
     // Instantiate a new PDO object with a persistent connection.
     $this->pdo = new PDO($this->dsn_string, $user, $pass, $options);
     // Define prepared statements for improved performance.
     $this->create = $this->pdo->prepare("INSERT INTO cache (id, expires, data) VALUES (:id, :expires, :data)");
     $this->read = $this->pdo->prepare("SELECT id, expires, data FROM cache WHERE id = :id");
     $this->reset = $this->pdo->prepare("UPDATE cache SET expires = :expires WHERE id = :id");
     $this->delete = $this->pdo->prepare("DELETE FROM cache WHERE id = :id");
 }
开发者ID:anil-kodali,项目名称:aws-sdk-for-php,代码行数:55,代码来源:cachepdo.class.php

示例10: __construct

 /**
  * Method: __construct()
  * 	The constructor
  *
  * Access:
  * 	public
  *
  * Parameters:
  * 	name - _string_ (Required) A name to uniquely identify the cache object.
  * 	location - _string_ (Required) The location to store the cache object in. This may vary by cache method.
  * 	expires - _integer_ (Required) The number of seconds until a cache object is considered stale.
  * 	gzip - _boolean_ (Optional) Whether data should be gzipped before being stored. Defaults to true.
  *
  * Returns:
  * 	_object_ Reference to the cache object.
  */
 public function __construct($name, $location, $expires, $gzip = true)
 {
     parent::__construct($name, null, $expires, $gzip);
     $this->id = $this->name;
 }
开发者ID:Webbiker,项目名称:Klompenschuurtje,代码行数:21,代码来源:cacheapc.class.php

示例11: deleteTestingInstance

 /**
  * Unit testing purpose only
  */
 public static function deleteTestingInstance()
 {
     self::$instance = null;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:7,代码来源:Cache.php

示例12: __construct

 /**
  * Constructs a new instance of this class.
  *
  * @param string $name (Required) A name to uniquely identify the cache object.
  * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL.
  * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0.
  * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true.
  * @return object Reference to the cache object.
  */
 public function __construct($name, $location = null, $expires = 0, $gzip = true)
 {
     parent::__construct($name, $location, $expires, $gzip);
     $this->id = $this->location . '/' . $this->name . '.cache';
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:14,代码来源:cachefile.class.php

示例13: __construct

 /**
  * Method: __construct()
  * 	The constructor
  * 
  * Access:
  * 	public
  * 
  * Parameters:
  * 	name - _string_ (Required) A name to uniquely identify the cache object.
  * 	location - _string_ (Required) The location to store the cache object in. This may vary by cache method.
  * 	expires - _integer_ (Required) The number of seconds until a cache object is considered stale.
  * 
  * Returns:
  * 	_object_ Reference to the cache object.
  * 
  * See Also:
  * 	Example Usage - http://tarzan-aws.com/docs/examples/cachecore/cache.phps
  */
 public function __construct($name, $location, $expires)
 {
     parent::__construct($name, $location, $expires);
     $this->id = $this->location . '/' . $this->name . '.cache';
 }
开发者ID:jpadilla,项目名称:codeigniter-s3-swfupload,代码行数:23,代码来源:_cachefile.class.php


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