コード例 #1
0
ファイル: Predis.php プロジェクト: pietro/predis
 public function setProfile($serverProfile)
 {
     if (!($serverProfile instanceof RedisServerProfile || is_string($serverProfile))) {
         throw new \InvalidArgumentException("Invalid type for server profile, \\Predis\\RedisServerProfile or string expected");
     }
     $this->_serverProfile = is_string($serverProfile) ? RedisServerProfile::get($serverProfile) : $serverProfile;
 }
コード例 #2
0
<?php

namespace Predis;

RedisServerProfile::registerProfile('\\Predis\\RedisServer_v1_0', '1.0');
RedisServerProfile::registerProfile('\\Predis\\RedisServer_v1_2_LongNames', '1.2');
RedisServerProfile::registerProfile('\\Predis\\RedisServer_v2_0_LongNames', '2.0');
class RedisServer_v1_0 extends \Predis\RedisServerProfile
{
    public function getVersion()
    {
        return '1.0';
    }
    public function getSupportedCommands()
    {
        return array('ping' => '\\Predis\\Compatibility\\v1_0\\Commands\\Ping', 'echo' => '\\Predis\\Compatibility\\v1_0\\Commands\\DoEcho', 'auth' => '\\Predis\\Compatibility\\v1_0\\Commands\\Auth', 'quit' => '\\Predis\\Compatibility\\v1_0\\Commands\\Quit', 'set' => '\\Predis\\Compatibility\\v1_0\\Commands\\Set', 'setnx' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetPreserve', 'setPreserve' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetPreserve', 'get' => '\\Predis\\Compatibility\\v1_0\\Commands\\Get', 'mget' => '\\Predis\\Compatibility\\v1_0\\Commands\\GetMultiple', 'getMultiple' => '\\Predis\\Compatibility\\v1_0\\Commands\\GetMultiple', 'getset' => '\\Predis\\Compatibility\\v1_0\\Commands\\GetSet', 'getSet' => '\\Predis\\Compatibility\\v1_0\\Commands\\GetSet', 'incr' => '\\Predis\\Compatibility\\v1_0\\Commands\\Increment', 'increment' => '\\Predis\\Compatibility\\v1_0\\Commands\\Increment', 'incrby' => '\\Predis\\Compatibility\\v1_0\\Commands\\IncrementBy', 'incrementBy' => '\\Predis\\Compatibility\\v1_0\\Commands\\IncrementBy', 'decr' => '\\Predis\\Compatibility\\v1_0\\Commands\\Decrement', 'decrement' => '\\Predis\\Compatibility\\v1_0\\Commands\\Decrement', 'decrby' => '\\Predis\\Compatibility\\v1_0\\Commands\\DecrementBy', 'decrementBy' => '\\Predis\\Compatibility\\v1_0\\Commands\\DecrementBy', 'exists' => '\\Predis\\Compatibility\\v1_0\\Commands\\Exists', 'del' => '\\Predis\\Compatibility\\v1_0\\Commands\\Delete', 'delete' => '\\Predis\\Compatibility\\v1_0\\Commands\\Delete', 'type' => '\\Predis\\Compatibility\\v1_0\\Commands\\Type', 'keys' => '\\Predis\\Compatibility\\v1_0\\Commands\\Keys', 'randomkey' => '\\Predis\\Compatibility\\v1_0\\Commands\\RandomKey', 'randomKey' => '\\Predis\\Compatibility\\v1_0\\Commands\\RandomKey', 'rename' => '\\Predis\\Compatibility\\v1_0\\Commands\\Rename', 'renamenx' => '\\Predis\\Compatibility\\v1_0\\Commands\\RenamePreserve', 'renamePreserve' => '\\Predis\\Compatibility\\v1_0\\Commands\\RenamePreserve', 'expire' => '\\Predis\\Compatibility\\v1_0\\Commands\\Expire', 'expireat' => '\\Predis\\Compatibility\\v1_0\\Commands\\ExpireAt', 'expireAt' => '\\Predis\\Compatibility\\v1_0\\Commands\\ExpireAt', 'dbsize' => '\\Predis\\Compatibility\\v1_0\\Commands\\DatabaseSize', 'databaseSize' => '\\Predis\\Compatibility\\v1_0\\Commands\\DatabaseSize', 'ttl' => '\\Predis\\Compatibility\\v1_0\\Commands\\TimeToLive', 'timeToLive' => '\\Predis\\Compatibility\\v1_0\\Commands\\TimeToLive', 'rpush' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPushTail', 'pushTail' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPushTail', 'lpush' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPushHead', 'pushHead' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPushHead', 'llen' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListLength', 'listLength' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListLength', 'lrange' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListRange', 'listRange' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListRange', 'ltrim' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListTrim', 'listTrim' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListTrim', 'lindex' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListIndex', 'listIndex' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListIndex', 'lset' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListSet', 'listSet' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListSet', 'lrem' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListRemove', 'listRemove' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListRemove', 'lpop' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPopFirst', 'popFirst' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPopFirst', 'rpop' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPopLast', 'popLast' => '\\Predis\\Compatibility\\v1_0\\Commands\\ListPopLast', 'sadd' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetAdd', 'setAdd' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetAdd', 'srem' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetRemove', 'setRemove' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetRemove', 'spop' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetPop', 'setPop' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetPop', 'smove' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetMove', 'setMove' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetMove', 'scard' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetCardinality', 'setCardinality' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetCardinality', 'sismember' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIsMember', 'setIsMember' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIsMember', 'sinter' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIntersection', 'setIntersection' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIntersection', 'sinterstore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIntersectionStore', 'setIntersectionStore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetIntersectionStore', 'sunion' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetUnion', 'setUnion' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetUnion', 'sunionstore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetUnionStore', 'setUnionStore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetUnionStore', 'sdiff' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetDifference', 'setDifference' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetDifference', 'sdiffstore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetDifferenceStore', 'setDifferenceStore' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetDifferenceStore', 'smembers' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetMembers', 'setMembers' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetMembers', 'srandmember' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetRandomMember', 'setRandomMember' => '\\Predis\\Compatibility\\v1_0\\Commands\\SetRandomMember', 'select' => '\\Predis\\Compatibility\\v1_0\\Commands\\SelectDatabase', 'selectDatabase' => '\\Predis\\Compatibility\\v1_0\\Commands\\SelectDatabase', 'move' => '\\Predis\\Compatibility\\v1_0\\Commands\\MoveKey', 'moveKey' => '\\Predis\\Compatibility\\v1_0\\Commands\\MoveKey', 'flushdb' => '\\Predis\\Compatibility\\v1_0\\Commands\\FlushDatabase', 'flushDatabase' => '\\Predis\\Compatibility\\v1_0\\Commands\\FlushDatabase', 'flushall' => '\\Predis\\Compatibility\\v1_0\\Commands\\FlushAll', 'flushDatabases' => '\\Predis\\Compatibility\\v1_0\\Commands\\FlushAll', 'sort' => '\\Predis\\Compatibility\\v1_0\\Commands\\Sort', 'info' => '\\Predis\\Compatibility\\v1_0\\Commands\\Info', 'slaveof' => '\\Predis\\Compatibility\\v1_0\\Commands\\SlaveOf', 'slaveOf' => '\\Predis\\Compatibility\\v1_0\\Commands\\SlaveOf', 'save' => '\\Predis\\Compatibility\\v1_0\\Commands\\Save', 'bgsave' => '\\Predis\\Compatibility\\v1_0\\Commands\\BackgroundSave', 'backgroundSave' => '\\Predis\\Compatibility\\v1_0\\Commands\\BackgroundSave', 'lastsave' => '\\Predis\\Compatibility\\v1_0\\Commands\\LastSave', 'lastSave' => '\\Predis\\Compatibility\\v1_0\\Commands\\LastSave', 'shutdown' => '\\Predis\\Compatibility\\v1_0\\Commands\\Shutdown');
    }
}
class RedisServer_v1_2_LongNames extends \Predis\RedisServerProfile
{
    public function getVersion()
    {
        return '1.2';
    }
    public function getSupportedCommands()
    {
        return array('ping' => '\\Predis\\Commands\\Ping', 'echo' => '\\Predis\\Commands\\DoEcho', 'auth' => '\\Predis\\Commands\\Auth', 'quit' => '\\Predis\\Commands\\Quit', 'set' => '\\Predis\\Commands\\Set', 'setnx' => '\\Predis\\Commands\\SetPreserve', 'setPreserve' => '\\Predis\\Commands\\SetPreserve', 'mset' => '\\Predis\\Commands\\SetMultiple', 'setMultiple' => '\\Predis\\Commands\\SetMultiple', 'msetnx' => '\\Predis\\Commands\\SetMultiplePreserve', 'setMultiplePreserve' => '\\Predis\\Commands\\SetMultiplePreserve', 'get' => '\\Predis\\Commands\\Get', 'mget' => '\\Predis\\Commands\\GetMultiple', 'getMultiple' => '\\Predis\\Commands\\GetMultiple', 'getset' => '\\Predis\\Commands\\GetSet', 'getSet' => '\\Predis\\Commands\\GetSet', 'incr' => '\\Predis\\Commands\\Increment', 'increment' => '\\Predis\\Commands\\Increment', 'incrby' => '\\Predis\\Commands\\IncrementBy', 'incrementBy' => '\\Predis\\Commands\\IncrementBy', 'decr' => '\\Predis\\Commands\\Decrement', 'decrement' => '\\Predis\\Commands\\Decrement', 'decrby' => '\\Predis\\Commands\\DecrementBy', 'decrementBy' => '\\Predis\\Commands\\DecrementBy', 'exists' => '\\Predis\\Commands\\Exists', 'del' => '\\Predis\\Commands\\Delete', 'delete' => '\\Predis\\Commands\\Delete', 'type' => '\\Predis\\Commands\\Type', 'keys' => '\\Predis\\Commands\\Keys_v1_2', 'randomkey' => '\\Predis\\Commands\\RandomKey', 'randomKey' => '\\Predis\\Commands\\RandomKey', 'rename' => '\\Predis\\Commands\\Rename', 'renamenx' => '\\Predis\\Commands\\RenamePreserve', 'renamePreserve' => '\\Predis\\Commands\\RenamePreserve', 'expire' => '\\Predis\\Commands\\Expire', 'expireat' => '\\Predis\\Commands\\ExpireAt', 'expireAt' => '\\Predis\\Commands\\ExpireAt', 'dbsize' => '\\Predis\\Commands\\DatabaseSize', 'databaseSize' => '\\Predis\\Commands\\DatabaseSize', 'ttl' => '\\Predis\\Commands\\TimeToLive', 'timeToLive' => '\\Predis\\Commands\\TimeToLive', 'rpush' => '\\Predis\\Commands\\ListPushTail', 'pushTail' => '\\Predis\\Commands\\ListPushTail', 'lpush' => '\\Predis\\Commands\\ListPushHead', 'pushHead' => '\\Predis\\Commands\\ListPushHead', 'llen' => '\\Predis\\Commands\\ListLength', 'listLength' => '\\Predis\\Commands\\ListLength', 'lrange' => '\\Predis\\Commands\\ListRange', 'listRange' => '\\Predis\\Commands\\ListRange', 'ltrim' => '\\Predis\\Commands\\ListTrim', 'listTrim' => '\\Predis\\Commands\\ListTrim', 'lindex' => '\\Predis\\Commands\\ListIndex', 'listIndex' => '\\Predis\\Commands\\ListIndex', 'lset' => '\\Predis\\Commands\\ListSet', 'listSet' => '\\Predis\\Commands\\ListSet', 'lrem' => '\\Predis\\Commands\\ListRemove', 'listRemove' => '\\Predis\\Commands\\ListRemove', 'lpop' => '\\Predis\\Commands\\ListPopFirst', 'popFirst' => '\\Predis\\Commands\\ListPopFirst', 'rpop' => '\\Predis\\Commands\\ListPopLast', 'popLast' => '\\Predis\\Commands\\ListPopLast', 'rpoplpush' => '\\Predis\\Commands\\ListPopLastPushHead', 'listPopLastPushHead' => '\\Predis\\Commands\\ListPopLastPushHead', 'sadd' => '\\Predis\\Commands\\SetAdd', 'setAdd' => '\\Predis\\Commands\\SetAdd', 'srem' => '\\Predis\\Commands\\SetRemove', 'setRemove' => '\\Predis\\Commands\\SetRemove', 'spop' => '\\Predis\\Commands\\SetPop', 'setPop' => '\\Predis\\Commands\\SetPop', 'smove' => '\\Predis\\Commands\\SetMove', 'setMove' => '\\Predis\\Commands\\SetMove', 'scard' => '\\Predis\\Commands\\SetCardinality', 'setCardinality' => '\\Predis\\Commands\\SetCardinality', 'sismember' => '\\Predis\\Commands\\SetIsMember', 'setIsMember' => '\\Predis\\Commands\\SetIsMember', 'sinter' => '\\Predis\\Commands\\SetIntersection', 'setIntersection' => '\\Predis\\Commands\\SetIntersection', 'sinterstore' => '\\Predis\\Commands\\SetIntersectionStore', 'setIntersectionStore' => '\\Predis\\Commands\\SetIntersectionStore', 'sunion' => '\\Predis\\Commands\\SetUnion', 'setUnion' => '\\Predis\\Commands\\SetUnion', 'sunionstore' => '\\Predis\\Commands\\SetUnionStore', 'setUnionStore' => '\\Predis\\Commands\\SetUnionStore', 'sdiff' => '\\Predis\\Commands\\SetDifference', 'setDifference' => '\\Predis\\Commands\\SetDifference', 'sdiffstore' => '\\Predis\\Commands\\SetDifferenceStore', 'setDifferenceStore' => '\\Predis\\Commands\\SetDifferenceStore', 'smembers' => '\\Predis\\Commands\\SetMembers', 'setMembers' => '\\Predis\\Commands\\SetMembers', 'srandmember' => '\\Predis\\Commands\\SetRandomMember', 'setRandomMember' => '\\Predis\\Commands\\SetRandomMember', 'zadd' => '\\Predis\\Commands\\ZSetAdd', 'zsetAdd' => '\\Predis\\Commands\\ZSetAdd', 'zincrby' => '\\Predis\\Commands\\ZSetIncrementBy', 'zsetIncrementBy' => '\\Predis\\Commands\\ZSetIncrementBy', 'zrem' => '\\Predis\\Commands\\ZSetRemove', 'zsetRemove' => '\\Predis\\Commands\\ZSetRemove', 'zrange' => '\\Predis\\Commands\\ZSetRange', 'zsetRange' => '\\Predis\\Commands\\ZSetRange', 'zrevrange' => '\\Predis\\Commands\\ZSetReverseRange', 'zsetReverseRange' => '\\Predis\\Commands\\ZSetReverseRange', 'zrangebyscore' => '\\Predis\\Commands\\ZSetRangeByScore', 'zsetRangeByScore' => '\\Predis\\Commands\\ZSetRangeByScore', 'zcard' => '\\Predis\\Commands\\ZSetCardinality', 'zsetCardinality' => '\\Predis\\Commands\\ZSetCardinality', 'zscore' => '\\Predis\\Commands\\ZSetScore', 'zsetScore' => '\\Predis\\Commands\\ZSetScore', 'zremrangebyscore' => '\\Predis\\Commands\\ZSetRemoveRangeByScore', 'zsetRemoveRangeByScore' => '\\Predis\\Commands\\ZSetRemoveRangeByScore', 'select' => '\\Predis\\Commands\\SelectDatabase', 'selectDatabase' => '\\Predis\\Commands\\SelectDatabase', 'move' => '\\Predis\\Commands\\MoveKey', 'moveKey' => '\\Predis\\Commands\\MoveKey', 'flushdb' => '\\Predis\\Commands\\FlushDatabase', 'flushDatabase' => '\\Predis\\Commands\\FlushDatabase', 'flushall' => '\\Predis\\Commands\\FlushAll', 'flushDatabases' => '\\Predis\\Commands\\FlushAll', 'sort' => '\\Predis\\Commands\\Sort', 'info' => '\\Predis\\Commands\\Info', 'slaveof' => '\\Predis\\Commands\\SlaveOf', 'slaveOf' => '\\Predis\\Commands\\SlaveOf', 'save' => '\\Predis\\Commands\\Save', 'bgsave' => '\\Predis\\Commands\\BackgroundSave', 'backgroundSave' => '\\Predis\\Commands\\BackgroundSave', 'lastsave' => '\\Predis\\Commands\\LastSave', 'lastSave' => '\\Predis\\Commands\\LastSave', 'shutdown' => '\\Predis\\Commands\\Shutdown', 'bgrewriteaof' => '\\Predis\\Commands\\BackgroundRewriteAppendOnlyFile', 'backgroundRewriteAppendOnlyFile' => '\\Predis\\Commands\\BackgroundRewriteAppendOnlyFile');
    }
}
class RedisServer_v2_0_LongNames extends RedisServer_v1_2_LongNames
{
コード例 #3
0
ファイル: RedisVersion1_0.php プロジェクト: dgw/ThinkUp
<?php

namespace Predis;

RedisServerProfile::registerProfile('\\Predis\\RedisServer_v1_0', '1.0');
abstract class InlineCommand extends Command
{
    public function serializeRequest($command, $arguments)
    {
        if (isset($arguments[0]) && is_array($arguments[0])) {
            $arguments[0] = implode($arguments[0], ' ');
        }
        return $command . (count($arguments) > 0 ? ' ' . implode($arguments, ' ') . Protocol::NEWLINE : Protocol::NEWLINE);
    }
}
abstract class BulkCommand extends Command
{
    public function serializeRequest($command, $arguments)
    {
        $data = array_pop($arguments);
        if (is_array($data)) {
            $data = implode($data, ' ');
        }
        return $command . ' ' . implode($arguments, ' ') . ' ' . strlen($data) . Protocol::NEWLINE . $data . Protocol::NEWLINE;
    }
}
class RedisServer_v1_0 extends \Predis\RedisServerProfile
{
    public function getVersion()
    {
        return '1.0';
コード例 #4
0
ファイル: Predis.php プロジェクト: hubgit/libapi
 public function __construct($parameters = null, RedisServerProfile $serverProfile = null)
 {
     $this->setProfile($serverProfile ?: RedisServerProfile::getDefault());
     $this->setupConnection($parameters);
 }