I working on web application which uses mysql as backend and redis as caching server and i stored the records in mysql database as well as redis(using predis library).
During fetching the records from database,first check whether the key present(primary key i.e id) in redis,if "yes" get data directly from redis,otherwise hit the database for data.
Suppose database tables are posts,comments.
During storing data for posts,comments details,used posts,comments tables for storing respective data.
Comments table having foreign key of post table called post_id
At redis server,used hash key (id) both for posts,comments and but different fields for post,comments like post_{id} for post, comment_{id} for comment and stored values using hset,sadd redis commands in allposts,allcomments sets.
It is easy to perform join operation using normal sql query to fetch related data.
Is there any solutions for fetching related data in redis or predis ?