join - Proper strategy for Redis caching relational data -


we have following use case example:

we have users, stores, friends (relationships between users) , likes. store these tables in mysql , key-value stores in redis, in order read redis cache , not hit database. writes done both data stores. our app therefore fast, , scalable since hit database reads. using aws scalable redis. however, have problem when user logged in , have show list of stores, , of friends store. join, , redis not support joins directly. we'd know best way store , show data. ex: if should stored in redis table key value "store/user_who likes" , mantained every write, or maybe have hourly cron construct this. can read stored data or should construct join on demand? notice not facebook updates info in realtime, rather takes several minutes friend see of friends likes page have in common. in advance responses.

depends how important you. why not store each person's friends set, , each store's likes set, , when need friends given store, take sinter (set intersection) between two. should fast, , storing friends , store likes sets lot of nice operations well. not sure how you're using redis cache, use these cheaper memory replacement getting users' friends, stores' likes, etc...

as cron, not sure how help. redis more fast enough handle above sorts of writes. memory bottleneck first.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -