Ejemplo 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);
     }
 }
Ejemplo 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));
 }
Ejemplo 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;
 }
Ejemplo 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;