我正在使用memcache进行缓存(很明显),这很棒.但我也将它用作交叉请求/流程数据存储.例如,我在其中一个页面上进行了网络聊天,并使用memcache存储其中的在线用户列表.工作得很好但令我困扰的是,如果我必须刷新整个memcache服务器(无论出于何种原因)我放松了在线列表.我还用它来记录一些内容的视图(然后我定期更新数据库中的实际行),如果我清除了缓存,我会丢失所有关于视图的数据(从最后一次写入到db).
所以我要问的是:对于这类事情我应该使用什么而不是memcache?它需要快速并且最好将其数据存储在内存中.我认为一些noSQL产品在这里很合适,但我不知道哪一个.我想在未来使用一些我可以用于其他用例的东西,脑海中会想到分析(例如用户搜索的最多).
我正在使用PHP,所以它必须具有良好的绑定.
解决方法:
Redis!这就像关于类固醇的记忆(好的). Here are some drivers.
Redis is an advanced key-value store. It is similar to memcached but the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists, sets, and ordered sets. All this data types can be manipulated with atomic operations to push/pop elements, add/remove elements, perform server side union, intersection, difference between sets, and so forth. Redis supports different kind of sorting abilities.