I'm trying to maintain a lot of common objects that will be used by many pages, but am trying to avoid the hit of reloading the information from a file or database for every page request.
For example, if I want to build an NLS such that I can make a call to get a phrase/word in a particular language, it will require maintaining a translation file with 1,000 terms and every time a page is requested, I want to just have that in memory for quick access rather than rereading it from disk/database.
Another example is I have global properties for my web site that are stored in the database, but they are used so frequently that I'd like to avoid the current overhead of querying the database on every page request.
Any suggestions on how to do this?
(Moderators, I'm not sure if this posting should be under Theory and Design - please feel free to move this to the appropriate location)
Persistent objects?
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Save it in the session or put it into a faster form -- like a file. For the file you could put it in code or config or YAML or XML or serialize it or ...
But with PHP everything has to load every request. The choice is what sub-system to use. If you need more speed then put the above files on a RAM disk.
But with PHP everything has to load every request. The choice is what sub-system to use. If you need more speed then put the above files on a RAM disk.
(#10850)
Does this site receive a lot of traffic? If not, selecting 1 field (the serialized object) from a database using a query won't be that much hassle at all.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
impromptu77
- Forum Newbie
- Posts: 2
- Joined: Thu Oct 04, 2007 6:08 pm
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: