Exemple #1
0
 /**
  * Create instance.
  *
  * @param \PDO  $pdo               The PDO instance to use.
  * @param array $config            Optional configuration of table/column names; default is an empty array to use the defaults.
  * @param int   $defaultTimeToLive Optional default time-to-live value.
  */
 public function __construct(PDO $pdo, array $config = array(), $defaultTimeToLive = 0)
 {
     parent::__construct(self::DEFAULT_NAMESPACE_DELIMITER, $defaultTimeToLive);
     $this->pdo = $pdo;
     // use exception error mode
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->config = array_merge(array('t_cache' => 'cache', 'c_id' => 'id', 'c_entry' => 'entry', 'c_expires' => 'expires'), $config);
 }
Exemple #2
0
 /**
  * Create instance.
  *
  * @param \Redis $redis             The <code>Redis</code> instance to be used.
  * @param int    $defaultTimeToLive Optional default time-to-live value.
  */
 public function __construct(Redis $redis, $defaultTimeToLive = 0)
 {
     parent::__construct(self::DEFAULT_NAMESPACE_DELIMITER, $defaultTimeToLive);
     // need serialization
     if (Redis::SERIALIZER_NONE == $redis->getOption(Redis::OPT_SERIALIZER)) {
         $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
     }
     $this->redis = $redis;
 }
Exemple #3
0
 /**
  * Create instance.
  *
  * @param array $config            Optional config settings; default is an empty array.
  * @param int   $defaultTimeToLive Optional default time-to-live value.
  */
 public function __construct(array $config = array(), $defaultTimeToLive = 0)
 {
     parent::__construct(self::DEFAULT_NAMESPACE_DELIMITER, $defaultTimeToLive);
     if (class_exists('Memcache')) {
         $this->memcache = new Memcache();
         // merge with some defaults
         $config = array_merge(array('host' => 'localhost', 'port' => 11211, 'compress' => false), $config);
         if (!($connected = @$this->memcache->connect($config['host'], $config['port']))) {
             $this->memcache = null;
         }
     } else {
         $this->memcache = null;
     }
     $this->compress = array_key_exists('compress', $config) && $config['compress'] && defined('MEMCACHE_COMPRESSED') ? MEMCACHE_COMPRESSED : 0;
 }
Exemple #4
0
 /**
  * Create instance.
  *
  * @param \MongoCollection $mongoCollection   The mongo collection to use.
  * @param int              $defaultTimeToLive Optional default time-to-live value.
  */
 public function __construct(MongoCollection $mongoCollection, $defaultTimeToLive = 0)
 {
     parent::__construct(self::DEFAULT_NAMESPACE_DELIMITER, $defaultTimeToLive);
     $this->mongoCollection = $mongoCollection;
 }