Open nimaamiri92 opened 6 years ago
Please validate that the $redis
object can connect to the Redis server.
Im pretty sure!
without above pseudo code my $redis
object work fine, but when add this code give this error
Im pretty sure! without above pseudo code my
$redis
object work fine, but when add this code give this error
Did you check a result from $redis->connect();
? This is a good practice to use x-debug and store any results to variables like this:
$result = $redis->connect();
Im pretty sure! without above pseudo code my
$redis
object work fine, but when add this code give this errorDid you check a result from
$redis->connect();
? This is a good practice to use x-debug and store any results to variables like this:$result = $redis->connect();
You are right $redis->connect()
return null because that's void function.
but the $redis
variable contain:
Predis\Client {#806
#connection: Predis\Connection\StreamConnection {#810
-resource: stream resource {@496
timed_out: false
blocked: true
eof: false
stream_type: "tcp_socket/ssl"
mode: "r+"
unread_bytes: 0
seekable: false
options: []
}
-cachedId: null
#parameters: Predis\Connection\Parameters {#808
-parameters: array:3 [
"scheme" => "tcp"
"host" => "127.0.0.1"
"port" => 6379
]
}
#initCommands: []
}
#options: Predis\Configuration\Options {#807
#input: []
#options: array:2 [
"connections" => Predis\Connection\Factory {#809
-defaults: []
#schemes: array:6 [
"tcp" => "Predis\Connection\StreamConnection"
"unix" => "Predis\Connection\StreamConnection"
"tls" => "Predis\Connection\StreamConnection"
"redis" => "Predis\Connection\StreamConnection"
"rediss" => "Predis\Connection\StreamConnection"
"http" => "Predis\Connection\WebdisConnection"
]
}
"profile" => Predis\Profile\RedisVersion320 {#812
-commands: array:159 [
"EXISTS" => "Predis\Command\KeyExists"
"DEL" => "Predis\Command\KeyDelete"
"TYPE" => "Predis\Command\KeyType"
"KEYS" => "Predis\Command\KeyKeys"
"RANDOMKEY" => "Predis\Command\KeyRandom"
"RENAME" => "Predis\Command\KeyRename"
"RENAMENX" => "Predis\Command\KeyRenamePreserve"
"EXPIRE" => "Predis\Command\KeyExpire"
"EXPIREAT" => "Predis\Command\KeyExpireAt"
"TTL" => "Predis\Command\KeyTimeToLive"
"MOVE" => "Predis\Command\KeyMove"
"SORT" => "Predis\Command\KeySort"
"DUMP" => "Predis\Command\KeyDump"
"RESTORE" => "Predis\Command\KeyRestore"
"SET" => "Predis\Command\StringSet"
"SETNX" => "Predis\Command\StringSetPreserve"
"MSET" => "Predis\Command\StringSetMultiple"
"MSETNX" => "Predis\Command\StringSetMultiplePreserve"
"GET" => "Predis\Command\StringGet"
"MGET" => "Predis\Command\StringGetMultiple"
"GETSET" => "Predis\Command\StringGetSet"
"INCR" => "Predis\Command\StringIncrement"
"INCRBY" => "Predis\Command\StringIncrementBy"
"DECR" => "Predis\Command\StringDecrement"
"DECRBY" => "Predis\Command\StringDecrementBy"
"RPUSH" => "Predis\Command\ListPushTail"
"LPUSH" => "Predis\Command\ListPushHead"
"LLEN" => "Predis\Command\ListLength"
"LRANGE" => "Predis\Command\ListRange"
"LTRIM" => "Predis\Command\ListTrim"
"LINDEX" => "Predis\Command\ListIndex"
"LSET" => "Predis\Command\ListSet"
"LREM" => "Predis\Command\ListRemove"
"LPOP" => "Predis\Command\ListPopFirst"
"RPOP" => "Predis\Command\ListPopLast"
"RPOPLPUSH" => "Predis\Command\ListPopLastPushHead"
"SADD" => "Predis\Command\SetAdd"
"SREM" => "Predis\Command\SetRemove"
"SPOP" => "Predis\Command\SetPop"
"SMOVE" => "Predis\Command\SetMove"
"SCARD" => "Predis\Command\SetCardinality"
"SISMEMBER" => "Predis\Command\SetIsMember"
"SINTER" => "Predis\Command\SetIntersection"
"SINTERSTORE" => "Predis\Command\SetIntersectionStore"
"SUNION" => "Predis\Command\SetUnion"
"SUNIONSTORE" => "Predis\Command\SetUnionStore"
"SDIFF" => "Predis\Command\SetDifference"
"SDIFFSTORE" => "Predis\Command\SetDifferenceStore"
"SMEMBERS" => "Predis\Command\SetMembers"
"SRANDMEMBER" => "Predis\Command\SetRandomMember"
"ZADD" => "Predis\Command\ZSetAdd"
"ZINCRBY" => "Predis\Command\ZSetIncrementBy"
"ZREM" => "Predis\Command\ZSetRemove"
"ZRANGE" => "Predis\Command\ZSetRange"
"ZREVRANGE" => "Predis\Command\ZSetReverseRange"
"ZRANGEBYSCORE" => "Predis\Command\ZSetRangeByScore"
"ZCARD" => "Predis\Command\ZSetCardinality"
"ZSCORE" => "Predis\Command\ZSetScore"
"ZREMRANGEBYSCORE" => "Predis\Command\ZSetRemoveRangeByScore"
"PING" => "Predis\Command\ConnectionPing"
"AUTH" => "Predis\Command\ConnectionAuth"
"SELECT" => "Predis\Command\ConnectionSelect"
"ECHO" => "Predis\Command\ConnectionEcho"
"QUIT" => "Predis\Command\ConnectionQuit"
"INFO" => "Predis\Command\ServerInfoV26x"
"SLAVEOF" => "Predis\Command\ServerSlaveOf"
"MONITOR" => "Predis\Command\ServerMonitor"
"DBSIZE" => "Predis\Command\ServerDatabaseSize"
"FLUSHDB" => "Predis\Command\ServerFlushDatabase"
"FLUSHALL" => "Predis\Command\ServerFlushAll"
"SAVE" => "Predis\Command\ServerSave"
"BGSAVE" => "Predis\Command\ServerBackgroundSave"
"LASTSAVE" => "Predis\Command\ServerLastSave"
"SHUTDOWN" => "Predis\Command\ServerShutdown"
"BGREWRITEAOF" => "Predis\Command\ServerBackgroundRewriteAOF"
"SETEX" => "Predis\Command\StringSetExpire"
"APPEND" => "Predis\Command\StringAppend"
"SUBSTR" => "Predis\Command\StringSubstr"
"BLPOP" => "Predis\Command\ListPopFirstBlocking"
"BRPOP" => "Predis\Command\ListPopLastBlocking"
"ZUNIONSTORE" => "Predis\Command\ZSetUnionStore"
"ZINTERSTORE" => "Predis\Command\ZSetIntersectionStore"
"ZCOUNT" => "Predis\Command\ZSetCount"
"ZRANK" => "Predis\Command\ZSetRank"
"ZREVRANK" => "Predis\Command\ZSetReverseRank"
"ZREMRANGEBYRANK" => "Predis\Command\ZSetRemoveRangeByRank"
"HSET" => "Predis\Command\HashSet"
"HSETNX" => "Predis\Command\HashSetPreserve"
"HMSET" => "Predis\Command\HashSetMultiple"
"HINCRBY" => "Predis\Command\HashIncrementBy"
"HGET" => "Predis\Command\HashGet"
"HMGET" => "Predis\Command\HashGetMultiple"
"HDEL" => "Predis\Command\HashDelete"
"HEXISTS" => "Predis\Command\HashExists"
"HLEN" => "Predis\Command\HashLength"
"HKEYS" => "Predis\Command\HashKeys"
"HVALS" => "Predis\Command\HashValues"
"HGETALL" => "Predis\Command\HashGetAll"
"MULTI" => "Predis\Command\TransactionMulti"
"EXEC" => "Predis\Command\TransactionExec"
"DISCARD" => "Predis\Command\TransactionDiscard"
"SUBSCRIBE" => "Predis\Command\PubSubSubscribe"
"UNSUBSCRIBE" => "Predis\Command\PubSubUnsubscribe"
"PSUBSCRIBE" => "Predis\Command\PubSubSubscribeByPattern"
"PUNSUBSCRIBE" => "Predis\Command\PubSubUnsubscribeByPattern"
"PUBLISH" => "Predis\Command\PubSubPublish"
"CONFIG" => "Predis\Command\ServerConfig"
"PERSIST" => "Predis\Command\KeyPersist"
"STRLEN" => "Predis\Command\StringStrlen"
"SETRANGE" => "Predis\Command\StringSetRange"
"GETRANGE" => "Predis\Command\StringGetRange"
"SETBIT" => "Predis\Command\StringSetBit"
"GETBIT" => "Predis\Command\StringGetBit"
"RPUSHX" => "Predis\Command\ListPushTailX"
"LPUSHX" => "Predis\Command\ListPushHeadX"
"LINSERT" => "Predis\Command\ListInsert"
"BRPOPLPUSH" => "Predis\Command\ListPopLastPushHeadBlocking"
"ZREVRANGEBYSCORE" => "Predis\Command\ZSetReverseRangeByScore"
"WATCH" => "Predis\Command\TransactionWatch"
"UNWATCH" => "Predis\Command\TransactionUnwatch"
"OBJECT" => "Predis\Command\ServerObject"
"SLOWLOG" => "Predis\Command\ServerSlowlog"
"CLIENT" => "Predis\Command\ServerClient"
"PTTL" => "Predis\Command\KeyPreciseTimeToLive"
"PEXPIRE" => "Predis\Command\KeyPreciseExpire"
"PEXPIREAT" => "Predis\Command\KeyPreciseExpireAt"
"MIGRATE" => "Predis\Command\KeyMigrate"
"PSETEX" => "Predis\Command\StringPreciseSetExpire"
"INCRBYFLOAT" => "Predis\Command\StringIncrementByFloat"
"BITOP" => "Predis\Command\StringBitOp"
"BITCOUNT" => "Predis\Command\StringBitCount"
"HINCRBYFLOAT" => "Predis\Command\HashIncrementByFloat"
"EVAL" => "Predis\Command\ServerEval"
"EVALSHA" => "Predis\Command\ServerEvalSHA"
"SCRIPT" => "Predis\Command\ServerScript"
"TIME" => "Predis\Command\ServerTime"
"SENTINEL" => "Predis\Command\ServerSentinel"
"SCAN" => "Predis\Command\KeyScan"
"BITPOS" => "Predis\Command\StringBitPos"
"SSCAN" => "Predis\Command\SetScan"
"ZSCAN" => "Predis\Command\ZSetScan"
"ZLEXCOUNT" => "Predis\Command\ZSetLexCount"
"ZRANGEBYLEX" => "Predis\Command\ZSetRangeByLex"
"ZREMRANGEBYLEX" => "Predis\Command\ZSetRemoveRangeByLex"
"ZREVRANGEBYLEX" => "Predis\Command\ZSetReverseRangeByLex"
"HSCAN" => "Predis\Command\HashScan"
"PUBSUB" => "Predis\Command\PubSubPubsub"
"PFADD" => "Predis\Command\HyperLogLogAdd"
"PFCOUNT" => "Predis\Command\HyperLogLogCount"
"PFMERGE" => "Predis\Command\HyperLogLogMerge"
"COMMAND" => "Predis\Command\ServerCommand"
"HSTRLEN" => "Predis\Command\HashStringLength"
"BITFIELD" => "Predis\Command\StringBitField"
"GEOADD" => "Predis\Command\GeospatialGeoAdd"
"GEOHASH" => "Predis\Command\GeospatialGeoHash"
"GEOPOS" => "Predis\Command\GeospatialGeoPos"
"GEODIST" => "Predis\Command\GeospatialGeoDist"
"GEORADIUS" => "Predis\Command\GeospatialGeoRadius"
"GEORADIUSBYMEMBER" => "Predis\Command\GeospatialGeoRadiusByMember"
]
-processor: null
}
]
#handlers: array:6 [
"cluster" => "Predis\Configuration\ClusterOption"
"connections" => "Predis\Configuration\ConnectionFactoryOption"
"exceptions" => "Predis\Configuration\ExceptionsOption"
"prefix" => "Predis\Configuration\PrefixOption"
"profile" => "Predis\Configuration\ProfileOption"
"replication" => "Predis\Configuration\ReplicationOption"
]
}
-profile: Predis\Profile\RedisVersion320 {#812}
}
Does Client
object have any isConnected()
method or another way to check connection?
This is a very optimistic way to use Client
in the next line after $redis->connect();
.
Does
Client
object have anyisConnected()
method or another way to check connection? This is a very optimistic way to useClient
in the next line after$redis->connect();
.
Yes, it has and return Ture
What is this this error?
It's not possible to acquire a lock because at least half of the Redis serv er are not available.
This is my code: