问题描述
对于我编写的一个小型PHP应用程序,我们需要存储大量具有哈希键和一些简单字段值('host','path')的记录。例如:
'4420ffb32a'=> array(
'host'=>'127.0.0.1',
'path'=>'path / to / resource',
);
对于这样的数据,最好的永久存储是什么? MySQL会是最好的选择,还是对于这样简单的数据呢?
简短答案:。 长答案:
您基本上有三个选项:关系数据库,文件存储或其他。
一个关系数据库肯定是过度的。也就是说,如果这是已经有一个MySQL或其他数据库的应用程序的一部分,我会去的。同样,文件存储可以方便地(例如写入一堆XML文件),但磁盘I / O可能很慢。
现在在其他类别,您有一些非常好的NoSQL选项,例如或。
如果您不太担心数据的持久性,我建议memcache。它轻量级,易于运行,还有一个,使用它很容易。它是为这样的键值存储。
内存缓存的一个缺点是所有的数据丢失第二个memcache服务停止。这是的来源。它是一个开源的memcache分支,是协议兼容的,意思是它将与所有现有的客户端库一起使用。但是,它可以持久保存您的数据,实际提供一致性和可靠性,而内存缓存本身不能使用。
For a small PHP app I am writing, we need to store a large number of records that have a hash key, and a few simple field values ('host', 'path'). eg:
'4420ffb32a' => array(
'host' => '127.0.0.1',
'path' => 'path/to/resource',
);
What is the best persistent storage for data like this? Would MySQL be the best choice, or is it overkill for such simple data? What would give the best performance?
Short answer: Membase.
Long answer:
You basically have three options: a relational database, file storage, or something else.
Like you said, a relational database could definitely be overkill. That said, if this is part of an application that already has a MySQL or other database, I would go with that. Likewise, file storage can be handy sometimes (writing to a bunch of XML files, for example), but disk I/O can be slow.
Now in the other category, you have some great NoSQL options like CouchDB or Memcached.
If you aren't too worried about the persistence of your data, I'd recommend memcache. It's lightweight, easy to get running, and there is a Memcache PHP extension that makes using it easy. It is made for key-value storage like this.
The one drawback memcache has is that all your data is lost the second the memcache service stops. This is where Membase comes in. It is an open-source fork of memcache that is protocol-compatible, meaning it will work with all existing client libraries. However, it can persist your data and actually provide consistency and reliability, something memcache can't on its own.
这篇关于key->值数据有什么好的,快速的持久存储选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!