Reputation: 16587
Hi I'm fairly new to Redis and Currently face a problem. My problem is "I don't know which way is better performance"
Way#1 : Cache All data to Redis and then Query to it ( I don't know is it possible to Query to Redis ? if possible How ? )
for example in following table cache all data to single Key ( By this way in my table we have 1 key ) and then Query for users with same City.
Way#2 : Cache all users with same City in separate Key ( By this way in my table we have 4 key ) and then Fetch each Key separately.
Upvotes: 0
Views: 155
Reputation: 6351
Cache all users with same City in separate Key - the Redis way. Fast insert, fast get in cost of much memory consumption or some data redundancy.
In general you can't follow your way#1
example. Why not? Redis do not have any in box solutions for query data in sql terms. You can't do something like select something from somethere where criteria
in most of Redis data structures. You can write LUA script for complex map/redus solutioin on your data - but not in out of box.
You should remeber, each time you want to say Join this and this data
you should understand - you can do this only in client application space or in redis LUA script. Yes, you have some types in join
capacity with ZSET and SET's but it not that you require.
Upvotes: 2