Beispiel #1
0
 public static function getMultiple($ids = array())
 {
     if (!empty($ids)) {
         foreach ($ids as &$id) {
             $id = self::_getKey($id);
         }
         $rediska = Rediska::getDefaultInstance();
         return $rediska->get($ids);
     }
     return array();
 }
Beispiel #2
0
 /**
  * Constructor
  *
  * @param  array|Zend_Config $options
  * @param  null|Zend_Queue $queue
  * @return void
  */
 public function __construct($options, Zend_Queue $queue = null)
 {
     parent::__construct($options, $queue);
     $defaultInstance = Rediska::getDefaultInstance();
     if (empty($this->_options['driverOptions']) && $defaultInstance) {
         $this->_rediska = $defaultInstance;
     } else {
         $this->_rediska = new Rediska($this->_options['driverOptions']);
     }
     $this->_queues = new Rediska_Key_Set($this->_getKeyName('queues'));
     $this->_queues->setRediska($this->_rediska);
 }
Beispiel #3
0
 /**
  * Writer constructor
  * 
  * @param string            $keyName Log key name
  * @param Zend_Config|array $options Rediska options
  */
 public function __construct($keyName, $options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     $defaultInstance = Rediska::getDefaultInstance();
     if (empty($options) && $defaultInstance) {
         $rediska = $defaultInstance;
     } else {
         $rediska = new Rediska($options);
     }
     $this->_list = new Rediska_Key_List($keyName);
     $this->_list->setRediska($rediska);
 }
Beispiel #4
0
 /**
  * Construct save handler
  *
  * @param Zend_Config|array $options
  */
 public function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     // Set default lifetime
     $this->_options['lifetime'] = (int) ini_get('session.gc_maxlifetime');
     // Get Rediska instance
     $defaultInstance = Rediska::getDefaultInstance();
     if ($defaultInstance && !isset($options['rediskaOptions'])) {
         $this->_rediska = $defaultInstance;
     } else {
         $this->_rediska = new Rediska($options['rediskaOptions']);
         unset($options['rediskaOptions']);
     }
     $this->setOptions($options);
     Rediska_Zend_Session_Set::setSaveHandler($this);
     $this->_set = new Rediska_Zend_Session_Set();
 }
Beispiel #5
0
 /**
  * Construct save handler
  *
  * @param Zend_Config|array $options
  */
 public function __construct($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     }
     // Set default lifetime
     $this->_options['lifetime'] = (int) ini_get('session.gc_maxlifetime');
     $this->setOptions($options);
     foreach ($this->_options as $name => $value) {
         if (isset($options[$name])) {
             unset($options[$name]);
         }
     }
     $defaultInstance = Rediska::getDefaultInstance();
     if (empty($options) && $defaultInstance) {
         $this->_rediska = $defaultInstance;
     } else {
         $this->_rediska = new Rediska($options);
     }
     Rediska_Zend_Session_Set::setSaveHandler($this);
     $this->_set = new Rediska_Zend_Session_Set();
 }
Beispiel #6
0
 /**
  * Setup Rediska instance
  */
 protected function _setupRediskaDefaultInstance()
 {
     if (is_null($this->_rediska)) {
         $this->_rediska = Rediska::getDefaultInstance();
         if (is_null($this->_rediska)) {
             $this->_rediska = new Rediska();
         }
     }
 }
Beispiel #7
0
 function transformNamespace($name)
 {
     $rediska = Rediska::getDefaultInstance();
     if ($val = $rediska->get("sesh_namespace_{$name}")) {
         return $val;
     } else {
         while ($rediska->get('sesh_locked') == 1) {
             // wait 1/20th of a second until we check again
             time_nanosleep(0, 50000000);
         }
         $rediska->set('sesh_locked', 1);
         $charInt = $rediska->get("sesh_namespacechrs");
         if ($charInt > 0) {
             if ($charInt == 256) {
                 throw new Exception('You can only use 255 attributes per namespace!');
             }
             $char = chr($charInt);
             $rediska->set("sesh_namespace_{$name}", $char);
             $rediska->increment("sesh_namespacechrs", 1);
         } else {
             // chr(0) is NULL, hence starting with 1
             $char = chr(1);
             $rediska->set("sesh_namespace_{$name}", $char);
             $rediska->set("sesh_namespacechrs", 2);
         }
         $rediska->set('sesh_locked', 0);
         return $char;
     }
 }