Esempio n. 1
0
 public function __construct(array $config)
 {
     if (!extension_loaded('redis')) {
         throw Storage\Error::require_extension('redis');
     }
     if ($config) {
         $this->config = array_merge($this->config, $config);
     }
 }
Esempio n. 2
0
 /**
  * 魔法方法
  * 直接调用PDO连接对象
  *
  * @param string $fn
  * @param array $args
  * @access public
  * @return mixed
  */
 public function __call($fn, $args)
 {
     $dbh = $this->connect();
     if (method_exists($dbh, $fn)) {
         return call_user_func_array(array($dbh, $fn), $args);
     }
     throw Storage\Error::call_undefined($fn, get_class($this));
 }
Esempio n. 3
0
 public function setDispatcher($name, $callback)
 {
     if (!is_callable($callback)) {
         throw Storage\Error::not_callable("Storage dispatcher {$name}");
     }
     $this->dispatcher[$name] = $callback;
     return $this;
 }
Esempio n. 4
0
<?php

// README: Advanced Message Queue Protocol Service
namespace Lysine\Storage;

use AMQPChannel;
use AMQPConnection;
use AMQPEnvelope;
use AMQPExchange;
use AMQPQueue;
if (!extension_loaded('amqp')) {
    throw Error::require_extension('amqp');
}
class AMQP implements \Lysine\IStorage
{
    private $connection;
    private $channel;
    public function __construct(array $config)
    {
        $this->connection = new AMQPConnection(self::prepareConfig($config));
    }
    public function connection()
    {
        return $this->connection;
    }
    public function channel($new = false)
    {
        if (!$new && $this->channel) {
            return $this->channel;
        }
        $connection = $this->connection;