开发者

disk IO vs MySQL query in PHP

I'm writing a remote API in PHP that needs to perform a comparison against a supplied parameter in every call. The supplied parameter will 开发者_JAVA百科need to be checked against 1 to 50 dynamic values (around 15 bytes in length each) or so, depending on the internal state of the API.

My question is, for the purpose of making the calls as fast as possible, would it make more sense to simply load the comparison values from a flat file (perhaps even as an .inc to be parsed immediately)in each call, or load the comparison values from a MySQL table in each call. The cost of writing changes to these values is not important since that won't happen very often.

Thanks.


if you only have 50 items, just include them in your php code. you're already reading that file from disk anyway... and php has it's own bytecode caching. using mysql will necessitate that you open a socket and make a network request every time.


If you only have a maximum of 50 values, I'd load them from the database once, and cache them in memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜