如何知道redis命令是write还是readonly?

时间:2015-03-27 17:50:14

标签: redis jedis

我的意思是有一个命令用于检查redis命令是否只读?

is_readonly(command)

如果在Jedis中有命令会更好。

1 个答案:

答案 0 :(得分:1)

使用COMMAND,您可以获得带有命令标志的所有命令的列表,例如 readonly

所以这就是我最终得到的列表:

publish bgsave sunion readonly exists hstrlen lindex scan ping latency ttl wait zscore zrevrangebylex sscan geohash getbit hkeys zrange monitor llen save auth zcard shutdown sync dbsize subscribe zrangebylex zlexcount mget getrange bitpos config lrange replconf discard asking client pfselftest bgrewriteaof unsubscribe zrank readwrite hget bitcount randomkey time zrevrank sinter dump strlen unwatch smembers georadius lastsave slowlog sismember hexists multi sdiff geopos hscan script keys hvals pfcount zscan echo command select zcount substr pttl hlen info scard geodist srandmember hgetall cluster psync pubsub psubscribe zrevrange hmget object watch zrangebyscore get type zrevrangebyscore punsubscribe georadiusbymember

虽然您可能希望排除只读管理员命令 - 但他们不会更改数据但会导致副作用。这里有排除管理员的列表:

publish sunion readonly exists hstrlen lindex scan ping ttl wait zscore zrevrangebylex sscan geohash getbit hkeys zrange llen auth zcard dbsize subscribe zrangebylex zlexcount mget getrange bitpos lrange discard asking client pfselftest unsubscribe zrank readwrite hget bitcount randomkey time zrevrank sinter dump strlen unwatch smembers georadius lastsave slowlog sismember hexists multi sdiff geopos hscan script keys hvals pfcount zscan echo command select zcount substr pttl hlen info scard geodist srandmember hgetall pubsub psubscribe zrevrange hmget object watch zrangebyscore get type zrevrangebyscore punsubscribe georadiusbymember

更多信息:http://redis.io/commands/command#examples

我认为您还可以检查哪些命令可用于特定的redis服务器版本。