在laravel中使用redis自带方法的时候会发现许多原生的方法都不存在了,laravel对其进行了重新的封装但是在文档中并没有找到相关的资料最后在
vendorpredispredissrcProfileRedisProfile.php
该文件的createCommand方法重打印出
$this->commands
发现许多方法名是被重写的,以下为所有重新定义的方法名
array(151) { ["EXISTS"]=> string(24) "PredisCommandKeyExists" ["DEL"]=> string(24) "PredisCommandKeyDelete" ["TYPE"]=> string(22) "PredisCommandKeyType" ["KEYS"]=> string(22) "PredisCommandKeyKeys" ["RANDOMKEY"]=> string(24) "PredisCommandKeyRandom" ["RENAME"]=> string(24) "PredisCommandKeyRename" ["RENAMENX"]=> string(32) "PredisCommandKeyRenamePreserve" ["EXPIRE"]=> string(24) "PredisCommandKeyExpire" ["EXPIREAT"]=> string(26) "PredisCommandKeyExpireAt" ["TTL"]=> string(28) "PredisCommandKeyTimeToLive" ["MOVE"]=> string(22) "PredisCommandKeyMove" ["SORT"]=> string(22) "PredisCommandKeySort" ["DUMP"]=> string(22) "PredisCommandKeyDump" ["RESTORE"]=> string(25) "PredisCommandKeyRestore" ["SET"]=> string(24) "PredisCommandStringSet" ["SETNX"]=> string(32) "PredisCommandStringSetPreserve" ["MSET"]=> string(32) "PredisCommandStringSetMultiple" ["MSETNX"]=> string(40) "PredisCommandStringSetMultiplePreserve" ["GET"]=> string(24) "PredisCommandStringGet" ["MGET"]=> string(32) "PredisCommandStringGetMultiple" ["GETSET"]=> string(27) "PredisCommandStringGetSet" ["INCR"]=> string(30) "PredisCommandStringIncrement" ["INCRBY"]=> string(32) "PredisCommandStringIncrementBy" ["DECR"]=> string(30) "PredisCommandStringDecrement" ["DECRBY"]=> string(32) "PredisCommandStringDecrementBy" ["RPUSH"]=> string(27) "PredisCommandListPushTail" ["LPUSH"]=> string(27) "PredisCommandListPushHead" ["LLEN"]=> string(25) "PredisCommandListLength" ["LRANGE"]=> string(24) "PredisCommandListRange" ["LTRIM"]=> string(23) "PredisCommandListTrim" ["LINDEX"]=> string(24) "PredisCommandListIndex" ["LSET"]=> string(22) "PredisCommandListSet" ["LREM"]=> string(25) "PredisCommandListRemove" ["LPOP"]=> string(27) "PredisCommandListPopFirst" ["RPOP"]=> string(26) "PredisCommandListPopLast" ["RPOPLPUSH"]=> string(34) "PredisCommandListPopLastPushHead" ["SADD"]=> string(21) "PredisCommandSetAdd" ["SREM"]=> string(24) "PredisCommandSetRemove" ["SPOP"]=> string(21) "PredisCommandSetPop" ["SMOVE"]=> string(22) "PredisCommandSetMove" ["SCARD"]=> string(29) "PredisCommandSetCardinality" ["SISMEMBER"]=> string(26) "PredisCommandSetIsMember" ["SINTER"]=> string(30) "PredisCommandSetIntersection" ["SINTERSTORE"]=> string(35) "PredisCommandSetIntersectionStore" ["SUNION"]=> string(23) "PredisCommandSetUnion" ["SUNIONSTORE"]=> string(28) "PredisCommandSetUnionStore" ["SDIFF"]=> string(28) "PredisCommandSetDifference" ["SDIFFSTORE"]=> string(33) "PredisCommandSetDifferenceStore" ["SMEMBERS"]=> string(25) "PredisCommandSetMembers" ["SRANDMEMBER"]=> string(30) "PredisCommandSetRandomMember" ["ZADD"]=> string(22) "PredisCommandSetAdd" ["ZINCRBY"]=> string(30) "PredisCommandSetIncrementBy" ["ZREM"]=> string(25) "PredisCommandSetRemove" ["ZRANGE"]=> string(24) "PredisCommandSetRange" ["ZREVRANGE"]=> string(31) "PredisCommandSetReverseRange" ["ZRANGEBYSCORE"]=> string(31) "PredisCommandSetRangeByScore" ["ZCARD"]=> string(30) "PredisCommandSetCardinality" ["ZSCORE"]=> string(24) "PredisCommandSetScore" ["ZREMRANGEBYSCORE"]=> string(37) "PredisCommandSetRemoveRangeByScore" ["PING"]=> string(29) "PredisCommandConnectionPing" ["AUTH"]=> string(29) "PredisCommandConnectionAuth" ["SELECT"]=> string(31) "PredisCommandConnectionSelect" ["ECHO"]=> string(29) "PredisCommandConnectionEcho" ["QUIT"]=> string(29) "PredisCommandConnectionQuit" ["INFO"]=> string(29) "PredisCommandServerInfoV26x" ["SLAVEOF"]=> string(28) "PredisCommandServerSlaveOf" ["MONITOR"]=> string(28) "PredisCommandServerMonitor" ["DBSIZE"]=> string(33) "PredisCommandServerDatabaseSize" ["FLUSHDB"]=> string(34) "PredisCommandServerFlushDatabase" ["FLUSHALL"]=> string(29) "PredisCommandServerFlushAll" ["SAVE"]=> string(25) "PredisCommandServerSave" ["BGSAVE"]=> string(35) "PredisCommandServerBackgroundSave" ["LASTSAVE"]=> string(29) "PredisCommandServerLastSave" ["SHUTDOWN"]=> string(29) "PredisCommandServerShutdown" ["BGREWRITEAOF"]=> string(41) "PredisCommandServerBackgroundRewriteAOF" ["SETEX"]=> string(30) "PredisCommandStringSetExpire" ["APPEND"]=> string(27) "PredisCommandStringAppend" ["SUBSTR"]=> string(27) "PredisCommandStringSubstr" ["BLPOP"]=> string(35) "PredisCommandListPopFirstBlocking" ["BRPOP"]=> string(34) "PredisCommandListPopLastBlocking" ["ZUNIONSTORE"]=> string(29) "PredisCommandSetUnionStore" ["ZINTERSTORE"]=> string(36) "PredisCommandSetIntersectionStore" ["ZCOUNT"]=> string(24) "PredisCommandSetCount" ["ZRANK"]=> string(23) "PredisCommandSetRank" ["ZREVRANK"]=> string(30) "PredisCommandSetReverseRank" ["ZREMRANGEBYRANK"]=> string(36) "PredisCommandSetRemoveRangeByRank" ["HSET"]=> string(22) "PredisCommandHashSet" ["HSETNX"]=> string(30) "PredisCommandHashSetPreserve" ["HMSET"]=> string(30) "PredisCommandHashSetMultiple" ["HINCRBY"]=> string(30) "PredisCommandHashIncrementBy" ["HGET"]=> string(22) "PredisCommandHashGet" ["HMGET"]=> string(30) "PredisCommandHashGetMultiple" ["HDEL"]=> string(25) "PredisCommandHashDelete" ["HEXISTS"]=> string(25) "PredisCommandHashExists" ["HLEN"]=> string(25) "PredisCommandHashLength" ["HKEYS"]=> string(23) "PredisCommandHashKeys" ["HVALS"]=> string(25) "PredisCommandHashValues" ["HGETALL"]=> string(25) "PredisCommandHashGetAll" ["MULTI"]=> string(31) "PredisCommandTransactionMulti" ["EXEC"]=> string(30) "PredisCommandTransactionExec" ["DISCARD"]=> string(33) "PredisCommandTransactionDiscard" ["SUBSCRIBE"]=> string(30) "PredisCommandPubSubSubscribe" ["UNSUBSCRIBE"]=> string(32) "PredisCommandPubSubUnsubscribe" ["PSUBSCRIBE"]=> string(39) "PredisCommandPubSubSubscribeByPattern" ["PUNSUBSCRIBE"]=> string(41) "PredisCommandPubSubUnsubscribeByPattern" ["PUBLISH"]=> string(28) "PredisCommandPubSubPublish" ["CONFIG"]=> string(27) "PredisCommandServerConfig" ["PERSIST"]=> string(25) "PredisCommandKeyPersist" ["STRLEN"]=> string(27) "PredisCommandStringStrlen" ["SETRANGE"]=> string(29) "PredisCommandStringSetRange" ["GETRANGE"]=> string(29) "PredisCommandStringGetRange" ["SETBIT"]=> string(27) "PredisCommandStringSetBit" ["GETBIT"]=> string(27) "PredisCommandStringGetBit" ["RPUSHX"]=> string(28) "PredisCommandListPushTailX" ["LPUSHX"]=> string(28) "PredisCommandListPushHeadX" ["LINSERT"]=> string(25) "PredisCommandListInsert" ["BRPOPLPUSH"]=> string(42) "PredisCommandListPopLastPushHeadBlocking" ["ZREVRANGEBYSCORE"]=> string(38) "PredisCommandSetReverseRangeByScore" ["WATCH"]=> string(31) "PredisCommandTransactionWatch" ["UNWATCH"]=> string(33) "PredisCommandTransactionUnwatch" ["OBJECT"]=> string(27) "PredisCommandServerObject" ["SLOWLOG"]=> string(28) "PredisCommandServerSlowlog" ["CLIENT"]=> string(27) "PredisCommandServerClient" ["PTTL"]=> string(35) "PredisCommandKeyPreciseTimeToLive" ["PEXPIRE"]=> string(31) "PredisCommandKeyPreciseExpire" ["PEXPIREAT"]=> string(33) "PredisCommandKeyPreciseExpireAt" ["MIGRATE"]=> string(25) "PredisCommandKeyMigrate" ["PSETEX"]=> string(37) "PredisCommandStringPreciseSetExpire" ["INCRBYFLOAT"]=> string(37) "PredisCommandStringIncrementByFloat" ["BITOP"]=> string(26) "PredisCommandStringBitOp" ["BITCOUNT"]=> string(29) "PredisCommandStringBitCount" ["HINCRBYFLOAT"]=> string(35) "PredisCommandHashIncrementByFloat" ["EVAL"]=> string(25) "PredisCommandServerEval" ["EVALSHA"]=> string(28) "PredisCommandServerEvalSHA" ["SCRIPT"]=> string(27) "PredisCommandServerScript" ["TIME"]=> string(25) "PredisCommandServerTime" ["SENTINEL"]=> string(29) "PredisCommandServerSentinel" ["SCAN"]=> string(22) "PredisCommandKeyScan" ["BITPOS"]=> string(27) "PredisCommandStringBitPos" ["SSCAN"]=> string(22) "PredisCommandSetScan" ["ZSCAN"]=> string(23) "PredisCommandSetScan" ["ZLEXCOUNT"]=> string(27) "PredisCommandSetLexCount" ["ZRANGEBYLEX"]=> string(29) "PredisCommandSetRangeByLex" ["ZREMRANGEBYLEX"]=> string(35) "PredisCommandSetRemoveRangeByLex" ["ZREVRANGEBYLEX"]=> string(36) "PredisCommandSetReverseRangeByLex" ["HSCAN"]=> string(23) "PredisCommandHashScan" ["PUBSUB"]=> string(27) "PredisCommandPubSubPubsub" ["PFADD"]=> string(29) "PredisCommandHyperLogLogAdd" ["PFCOUNT"]=> string(31) "PredisCommandHyperLogLogCount" ["PFMERGE"]=> string(31) "PredisCommandHyperLogLogMerge" ["COMMAND"]=> string(28) "PredisCommandServerCommand" }
只要调用KEY就能使用对应的redis方法了,如:
Redis::EXISTS('key');//对应PredisCommandKeyExists