In-memory cache with LRU expiration

2019-06-14 10:16发布

问题:

I am looking for an in memory cache for my PHP powered website. It is not high traffic website, I just want to cache data and parts of some pages for improving performance. The data size will vary from a few bytes to few kBs. I am currently using xCache, and have no problem with it.

Is it better to switch to memcached or redis? Are there any better options?

回答1:

If you don't have any obvious problem, why do wanna switch right now? Memcached or redis are probably better but if you don't need them right now, it is better to leave them. As long as your caching strategy is sound and cache interface is abstracted you should be able to add them later when you actually feel the need to switch to a scalable cache.

Also xCache in PHP is an opcoder cache.. Memcache & redis are more or less like a out of proc key Value pair.. If your site is running on 2 or 3 server and you need the context b.w them shared not just kept individual instances, those caches will help.

--Sai



回答2:

Personally, I use APC, because I already use it for Opcode Caching. This way I have to maintain fewer things. Another reason for me to use APC is, that it is planned to be included in the next PHP version, so I feel more "stable" on it.

Though obviously: You should change your caching system, just for the sake of changing it ;) If XCache doesn't make any problems, you probably should just keep it.