Jump to content

Dynamic Data, Where and how to store..


RobertP

Recommended Posts

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!

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.