mysql - 将 perl 数组存储在内存中以供其他 perl 实例使用

标签 mysql arrays perl dbi dbd

我正在使用一个 perl 脚本,在接收到参数后,它会检查数据库中的一个值,然后相应地执行其他操作。由于流量在增加,因此正在执行大量 mysql 读/写操作,这可能会影响性能。

由于存储在 mysql 中的数据并不是很复杂,我想知道是否最好将一个数组存储在内存中,然后其他 perl 实例在运行时可以读取/修改该数组。

这可能吗?

最佳答案

您可以使用共享内存

IPC::SharedMem是底层核心模块

为了不重新发明轮子,请查看:

IPC::Shareable

IPC::Shareable allows you to tie a variable to shared memory making it easy to share the contents of that variable with other Perl processes. Scalars, arrays, and hashes can be tied. The variable being tied may contain arbitrarily complex data structures - including references to arrays, hashes of hashes, etc.

关于mysql - 将 perl 数组存储在内存中以供其他 perl 实例使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31175538/

相关文章:

php - 我可以将数组绑定(bind)到 PDO 查询中的 IN() 条件吗?

java - 读取文本文件并创建一个二维数组

arrays - 从 powershell 数组/集合/哈希表中删除一行

perl - 在脚本中更改工作目录的最佳做法是什么?

perl - 多语言 PSGI-web 部署

bash - 使用perl将文件中的变量内容替换为另一个变量内容

mysql - 删除mysql中的行

mysql - 复杂查询需要指导

php - 使用 php 和 mysql 数据库比较两个日期

Java Spring JDBC last_insert_id() 方法