Example #1
0
 /**
  * Create a new cache object
  *
  * @param string $location Location string (from SimplePie::$cache_location)
  * @param string $name Unique ID for the cache
  * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
  */
 public function __construct($location, $name, $type)
 {
     $this->options = array('user' => null, 'pass' => null, 'host' => '127.0.0.1', 'port' => '3306', 'path' => '', 'extras' => array('prefix' => ''));
     $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
     // Path is prefixed with a "/"
     $this->options['dbname'] = substr($this->options['path'], 1);
     try {
         $this->mysql = new PDO("mysql:dbname={$this->options['dbname']};host={$this->options['host']};port={$this->options['port']}", $this->options['user'], $this->options['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
     } catch (PDOException $e) {
         $this->mysql = null;
         return;
     }
     $this->id = $name . $type;
     if (!($query = $this->mysql->query('SHOW TABLES'))) {
         $this->mysql = null;
         return;
     }
     $db = array();
     while ($row = $query->fetchColumn()) {
         $db[] = $row;
     }
     if (!in_array($this->options['extras']['prefix'] . 'cache_data', $db)) {
         $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))');
         if ($query === false) {
             $this->mysql = null;
         }
     }
     if (!in_array($this->options['extras']['prefix'] . 'items', $db)) {
         $query = $this->mysql->exec('CREATE TABLE `' . $this->options['extras']['prefix'] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))');
         if ($query === false) {
             $this->mysql = null;
         }
     }
 }
Example #2
0
 public function __construct($url, $filename, $extension)
 {
     $this->options = array('host' => '127.0.0.1', 'port' => 11211, 'extras' => array('timeout' => 3600, 'prefix' => 'simplepie_'));
     $this->options = array_merge_recursive($this->options, SimplePie_Cache::parse_URL($url));
     $this->name = $this->options['extras']['prefix'] . md5("{$filename}:{$extension}");
     $this->cache = new Memcache();
     $this->cache->addServer($this->options['host'], (int) $this->options['port']);
 }
Example #3
0
 /**
  * Create a new cache object
  * @param string $location Location string (from SimplePie::$cache_location)
  * @param string $name     Unique ID for the cache
  * @param string $type     Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
  */
 public function __construct($location, $name, $type)
 {
     $this->options = array('host' => '127.0.0.1', 'port' => 11211, 'extras' => array('timeout' => 3600, 'prefix' => 'simplepie_'));
     $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
     $this->name = $this->options['extras']['prefix'] . md5("{$name}:{$type}");
     $this->cache = new Memcached();
     $this->cache->addServer($this->options['host'], (int) $this->options['port']);
 }
Example #4
0
 /**
  * Create a new cache object
  *
  * @param string $location Location string (from SimplePie::$cache_location)
  * @param string $name Unique ID for the cache
  * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
  */
 public function __construct($location, $name, $options = null)
 {
     //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
     $parsed = SimplePie_Cache::parse_URL($location);
     $redis = new Redis();
     $redis->connect($parsed['host'], $parsed['port']);
     $this->cache = $redis;
     if (!is_null($options) && is_array($options)) {
         $this->options = $options;
     } else {
         $this->options = array('prefix' => 'rss:simple_primary:', 'expire' => 0);
     }
     $this->name = $this->options['prefix'] . $name;
 }