最快的 PHP 内存缓存/哈希表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7309354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:27:10  来源:igfitidea点击:

Fastest PHP memory cache/hashtable

phpcachingmemory

提问by thwd

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

我正在寻找可用于 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?

你会推荐什么,为什么?

采纳答案by Gordon

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.

如果您尚未安装 APC 或 Memcached(或不想为此使用它们),您还可以创建一个 RAM 磁盘。然后使用file_get_contents()file_put_contents()其中文件名是您的键,文件内容是您的值。我没有这方面的数字,但应该很快。

回答by Arnaud Le Blanc

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

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

  • APCcan 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.

  • chdb是一个在 PHP 进程之间共享的只读哈希表:可能是最快的,对内存的影响更少。

  • Hidef允许使用 .ini 文件定义常量。当 php 模块启动时,常量被定义一次。

  • APC可以将变量存储在共享内存中,以便其他 PHP 进程可以使用它们。每次存储和获取变量时,它都会产生序列化和反序列化变量的开销。

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

查看其他人:http: //pecl.php.net/packages.php?catpid=3&catname=Caching

回答by v3rt1g0

回答by Karoly Horvath

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

如果您不打算修改数据(对于您的配置文件可能是这样),请使用chdb