mysql - "caching" an array of database values in php (2 options, which is better?) -


(I use the word var in the following because I'm not sure what I think is the global variable )

I want to cache the values ​​from a table in the database to save the repetitive questions. What I have done is making a singleton class, in which there is a function to check a var inside the class, if there is a key, if this happens then just return values ​​from var, if the database queries Does not load it and it does not load in Var and it will return it.

Or would it be a better way to use a global variable (does global variables have no importance, no files from this?) And a class at all.

Do not disturb or cache and ask the database every time the value is required.

Should I post with its source? / P>

It depends on your queries - how expensive and heavy is for the database? If this is a very simple and light question - I would say that caching is not needed (unless you actually have a high volume - thousands or lacs in a short time) for your simple recapitalization questions, your db may possibly include any kind of query cache - This will also speed things up

Caching to expensive questions makes more sense. After this you can use the memcache as suggested, you can also see the APC cache.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -