When using the following command when using redis, redis prompts an error:
127.0.0.1:6379> rpush aaa item
WRONGTYPE Operation against a key holding the wrong kind of value
It is because the key aaa
is already in the redis, and the value type corresponding to this key is not a list collection, but a string, so the error is eliminated when using rpush
.
1. Delete the key aaa
before. Rewrite
2. Use a key that does not exist in redis.
If you are not sure what type of key is before using it, you can use the type method to determine the key type first, and then decide to call the method.
127.0.0.1:6379> type aaa
>>> list