Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest PHP memory cache/hashtable [closed]

I'm looking for the fastest in-memory cache/hashtable available for PHP.

I will be storing some system-configuration values in it and I'm trying to get the least possible overhead.

The data will be small and granular.

What would you recommend and why?

like image 268
thwd Avatar asked Sep 05 '11 14:09

thwd


People also ask

Is Memcached faster than Redis?

Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.

Why Redis is better than memcache?

Memcached is designed for simplicity while Redis offers a rich set of features that make it effective for a wide range of use cases. Understand your requirements and what each engine offers to decide which solution better meets your needs.

Is Redis faster than memory?

Save this answer. Show activity on this post. Redis is a remote data structure server. It is certainly slower than just storing the data in local memory (since it involves socket roundtrips to fetch/store the data).

Is Memcache persistent?

When deciding whether to use Redis or Memcached a major difference between these two is data persistence. While Redis is an in-memory (mostly) data store and it is not volatile, Memcached is an in-memory cache and it is volatile.


2 Answers

If you dont have APC or Memcached installed already (or dont want to use them for this) you can also create a RAM disk. Then use file_get_contents() and file_put_contents() where filename is your key and the file content is your value. I dont have numbers for that, but it should be fast.

like image 120
Gordon Avatar answered Oct 03 '22 06:10

Gordon


  • chdb is a read-only hashtable shared across PHP processes: Probably the fastest and less memory-angry one.

  • Hidef allows to define constants using a .ini file. The constants are defined once, when the php module is started.

  • APC can store variables in shared memory, so that they are available to other PHP processes. It has the overhead of serializing and de-serializing variables each time you store and fetch them.

See others: http://pecl.php.net/packages.php?catpid=3&catname=Caching

like image 21
Arnaud Le Blanc Avatar answered Oct 03 '22 06:10

Arnaud Le Blanc