我正在使用一个 perl 脚本,在接收到参数后,它会检查数据库中的一个值,然后相应地执行其他操作。由于流量在增加,因此正在执行大量 mysql 读/写操作,这可能会影响性能。
由于存储在 mysql 中的数据并不是很复杂,我想知道是否最好将一个数组存储在内存中,然后其他 perl 实例在运行时可以读取/修改该数组。
这可能吗?
最佳答案
您可以使用共享内存
IPC::SharedMem是底层核心模块
为了不重新发明轮子,请查看:
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/