How to avoid wrongtype operation exception in Redis
Redis is currently one of the most popular caching framework getting used by various companies. Its java client Jedis is also quite popular among developer.s
One of the most useful feature of Redis is its ability to store various data structures like hash, sets, list etc. This helps in reduction in the number of lines of code a developer needs to write.
So for a given key you can set any data structure as a value, sometimes while retrieving the value back you might be interested in knowing which data structure was originally saved. If you had set a hash and trying to retrieve a set, you will get WRONGTYPE operation error. So we should always use ‘type’ command to check the type of data structure of the value. Something like this :
Type can be hash, list,set etc.