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


PHP CacheCore::__construct方法代码示例

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


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

示例1: __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

示例2: __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

示例3: __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

示例4: __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

示例5: __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

示例6: __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

示例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, $location, $expires);
     $this->id = $this->location . '/' . $this->name . '.cache';
 }
开发者ID:jpadilla,项目名称:codeigniter-s3-swfupload,代码行数:23,代码来源:_cachefile.class.php


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