Example #1
0
 /**
  * Constructor.
  *
  * @param \PDO  $pdo
  * @param array $options Array of options.
  */
 public function __construct(\PDO $pdo, array $options = null)
 {
     // Set some SQLite PRAGMA to speed things up.
     // @see http://www.sqlite.org/pragma.html
     // @see http://stackoverflow.com/questions/1711631/how-do-i-improve-the-performance-of-sqlite
     $pdo->exec('PRAGMA synchronous=OFF');
     $pdo->exec('PRAGMA journal_mode=MEMORY');
     $pdo->exec('PRAGMA temp_store=MEMORY');
     $pdo->exec('PRAGMA count_changes=false');
     parent::__construct($pdo, $options);
 }
Example #2
0
 /**
  * Factory pattern.
  *
  * @param  mixed                                   $mix      Either a supported client object e.g. '\Redis';
  *                                                           or one that implements \Apix\Cache\Adapter;
  *                                                           or an adapter name (string) e.g. "APC", "Runtime";
  *                                                           or even a plain array() or \ArrayObject.
  * @param  array                                   $options  An array of options
  * @param  boolean                                 $taggable Wether to return a taggable pool.
  * @return PsrCache\Pool|PsrCache\TaggablePool
  * @throws PsrCache\InvalidArgumentException
  * @throws Apix\Cache\Exception
  */
 public static function getPool($mix, array $options = array(), $taggable = false)
 {
     switch (true) {
         case is_a($mix, 'Apix\\Cache\\Adapter'):
             $class = $mix;
             break;
         case is_object($mix) && in_array($name = get_class($mix), self::$clients):
             if ($name == 'PDO') {
                 $name = 'Pdo\\' . AbstractPdo::getDriverName($mix);
             } else {
                 $name = isset(self::$adapters[$name]) ? self::$adapters[$name] : $name;
             }
             break;
         case is_string($mix) && in_array($name = strtolower($mix), $clients = array_map('strtolower', self::$clients)):
             $key = array_search($name, $clients);
             $name = self::$clients[$key];
             $name = $name == 'Array' || $name == 'ArrayObject' ? 'Runtime' : $name;
             $mix = null;
             break;
         case is_array($mix):
             $name = 'Runtime';
             $mix = null;
             break;
         default:
             throw new PsrCache\InvalidArgumentException(sprintf(self::ERROR, __CLASS__));
     }
     if (!isset($class)) {
         $class = '\\Apix\\Cache\\' . $name;
     }
     try {
         if (null === $mix) {
             $cache = new $class($options);
         } else {
             $cache = new $class($mix, $options);
         }
     } catch (\Exception $e) {
         throw new Cache\Exception($e);
     }
     return $taggable ? new PsrCache\TaggablePool($cache) : new PsrCache\Pool($cache);
 }
Example #3
0
 /**
  * Constructor.
  *
  * @param \PDO  $pdo
  * @param array $options Array of options.
  */
 public function __construct(\PDO $pdo, array $options = null)
 {
     parent::__construct($pdo, $options);
 }