Ejemplo n.º 1
0
 /**
  * Phalcon\Cache\Backend\Aerospike constructor
  *
  * @param  FrontendInterface $frontend Frontend Interface
  * @param  array             $options  Constructor options
  * @throws Exception
  */
 public function __construct(FrontendInterface $frontend, array $options)
 {
     if (!isset($options['hosts']) || !is_array($options['hosts'])) {
         throw new Exception('No hosts given in options');
     }
     if (isset($options['namespace'])) {
         $this->namespace = $options['namespace'];
     }
     if (isset($options['prefix'])) {
         $this->_prefix = $options['prefix'];
     }
     $persistent = false;
     if (isset($options['persistent'])) {
         $persistent = (bool) $options['persistent'];
     }
     $opts = [];
     if (isset($options['options']) && is_array($options['options'])) {
         $opts = $options['options'];
     }
     $this->db = new AerospikeDb(['hosts' => $options['hosts']], $persistent, $opts);
     if (!$this->db->isConnected()) {
         throw new Exception(sprintf("Aerospike failed to connect [%s]: %s", $this->db->errorno(), $this->db->error()));
     }
     parent::__construct($frontend, $options);
 }