RobertP Posted January 18, 2013 Share Posted January 18, 2013 So for my application, I have a few different types of 'dynamic data'. I need to read this data, and use it for almost every page. I would not like to always be querying the same data from a database, but at the same time I need a simple interface to edit the data. I know I will temporarily store the data in memcached, but where do I read the data from? Also, I will need a solution that does not involve memcached, as not every client that is using my application will have memcached installed / configured. One possible solution I thought of could be a php file with a json_encode'ed variable, for easy manipulation. A side note, all the data being store is multi-dimentional arrays, containing strings, integers and floats, if that makes a diffnerence. Hopfully this post does not confuse the f**k out of you! Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/ Share on other sites More sharing options...
Christian F. Posted January 18, 2013 Share Posted January 18, 2013 (edited) I'm sorry, but I think you're a bit too abstract in your description. I didn't quite grasp what you're looking for, other than you wanting to know how to best construct a cache solution for some data. Edited January 18, 2013 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406675 Share on other sites More sharing options...
RobertP Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) One scenario that i am using would be my dynamic menu structure. My application handles an infinite (per admin preference) menu items; where do i store this array, to be used on almost every page load? My current implementation is to read the php array from a file, already defined in a variable. (hard to manipulate) Note: I can not rely on memcache, as not every client will have it installed; however for the clients that do, they can feel the benefit. Edited January 18, 2013 by RobertP Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406788 Share on other sites More sharing options...
Jessica Posted January 18, 2013 Share Posted January 18, 2013 In a database. One scenario that i am using would be my dynamic menu structure. My application handles an infinite (per admin preference) menu items; where do i store this array, to be used on almost every page load? In a regular old mysql database. Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406813 Share on other sites More sharing options...
shlumph Posted January 18, 2013 Share Posted January 18, 2013 Store it in a database, but when pulling data check the cache first. When a user adds a new menu item, destroy the cache, pull from the database, and then store that data in cache for future lookups. Is this what you're looking to do? There are plenty of caching systems, besides memcache. You could even just write the serialized data to a file. This is what I did on my blog: (code) Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406817 Share on other sites More sharing options...
BagoZonde Posted January 18, 2013 Share Posted January 18, 2013 I don't know about best practice but in my own framework which is still under development I'm using includes as I'm working on very fast solution. For more constans data one of modules just creating array so it's a lot more faster than MySQL query. I was tested it for about 15000 records and it was a good choice I think... and less queries! Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406822 Share on other sites More sharing options...
RobertP Posted January 18, 2013 Author Share Posted January 18, 2013 Store it in a database, but when pulling data check the cache first. When a user adds a new menu item, destroy the cache, pull from the database, and then store that data in cache for future lookups. This seems to be the best route, but i will need to add additional cache protocols to my application. Thank you all for your replies. Quote Link to comment https://forums.phpfreaks.com/topic/273297-dynamic-data-where-and-how-to-store/#findComment-1406856 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.