I am developing a social network from scratch and need to store the
user’s frequently required data like his friendlist, groups, news-feed
post Ids, so that it can be accessed fast after each refresh rather
than querying the database each time it is asked. What would be a
better way to store this data?
The application is expected to bear heavy traffic.
I was thinking of storing this data in php objects after the user
login. I am using PHP OOPs model to interact with the database thus my
data is retrieved though objects & retrieved data is stored in objects
after query from database. So, Instead of destroying the object as
soon as its value has been passed once, I would retain the required
objects uptil the user is logged in.
Is this the correct way?
I am just a newbie..
Thanks..
Storing in a session… the whole data stored in session is loaded at script status. To sum it up:
Develop yourself simple caching class:
Then use those layout to write caching mechanism using: memcache / myisam table / apc / mongodb, etc. On everything beside files you can implement an ACID cache. The important thing is not choosing what you’ll use now, but implement something that’ll allow you to easily change it later 🙂
I don’t know if you need groups within your cache… if you do it’ll limit the technologies you can use (eg. to clean all caching data for specific user after updating one of his DB tables). Another good thing is to assign table name to each cache item, everything could be updated very easy then.