Fastest PHP memory cache/hashtable [closed]

2020-03-01 08:25发布

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?

5条回答
闹够了就滚
2楼-- · 2020-03-01 08:40
  • 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

查看更多
叛逆
3楼-- · 2020-03-01 08:47

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.

查看更多
贪生不怕死
4楼-- · 2020-03-01 08:49
可以哭但决不认输i
5楼-- · 2020-03-01 08:51

If your don't intend to modify data (probably true for your configuration files) then use chdb.

查看更多
登录 后发表回答