pornophobic Posted June 2, 2010 Share Posted June 2, 2010 Hi there, I've been looking around for the answer, or just even advice on if this is a good idea before I actually do it. I want to write a social script that has a live feed like facebook, etc. I don't want to have to call to the main database for fetching the recent items as it will load quite often through AJAX and this could create some problems, I think. I want to know if it's a good idea to use the MEMORY engine to cache recent items. (certain things will be cached in PHP variables.) If it is, how long is an ideal lifetime for cached items? I'm planning on having a sitewide feed (there aren't very many members yet) and a per-user feed that displays on their profile. If I do use the MEMORY engine, I plan on after a certain amount of time, or a certain amount of recent entries per user, the older entries will be moved to the main database and stored on the server in an xml file. These recent entries will either be for JIT xml or JSON encoded files so that they can load much faster. Is there any problems this could cause down the road? Would I just be better off using a file stream instead? I've considered a few options, this one seems ideal as I can keep it an ideal size using crontab and minimal coding. Quote Link to comment https://forums.phpfreaks.com/topic/203660-memory-engine-as-a-cache-for-feeds/ Share on other sites More sharing options...
fenway Posted June 5, 2010 Share Posted June 5, 2010 Well, the whole idea of caching is that it's faster -- and if your web server just serves up a static html page, rather than having to connect to a DB, it'll be much faster -- so MEMORY isn't going to help much. Quote Link to comment https://forums.phpfreaks.com/topic/203660-memory-engine-as-a-cache-for-feeds/#findComment-1068424 Share on other sites More sharing options...
pornophobic Posted September 4, 2010 Author Share Posted September 4, 2010 Sheesh. I've been very busy so apologies for the delayed response. The point in using MEMORY over HTML pages is that each feed is different for each user, so I would need an engine that is somewhat faster. I know that using a database is faster than file writing as writing files has a larger overhead as opposed to calling a database. MySQL, for instance, stores it's data in files on the hard disk and calls loads things from that data file. The objective of using the MEMORY engine would be that the data is in the RAM of my box and can be served faster than being called off of the disk. I'm not disagreeing or anything, I'm just curious as to what performance factors the MEMORY engine has with speed, etc. I've also looked at the InnoDB engine and I believe that it does store the data file right on the memory, so using that would be more ideal than MyISAM in my case. (I have lots of memory.) I'm still not sure what the purpose of using the MEMORY engine is, though. Quote Link to comment https://forums.phpfreaks.com/topic/203660-memory-engine-as-a-cache-for-feeds/#findComment-1107061 Share on other sites More sharing options...
fenway Posted September 6, 2010 Share Posted September 6, 2010 MEMORY is great for throw-away data -- caching included. Quote Link to comment https://forums.phpfreaks.com/topic/203660-memory-engine-as-a-cache-for-feeds/#findComment-1107746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.