小编典典

使用Redis作为Postgres的LRU缓存

redis

我有postgres 9.3
db,我想使用Redis来缓存对数据库的调用(基本上像memcached一样)。我遵循了这些文档,这意味着我已经基本配置了redis以用作LRU缓存。但是不确定下一步该怎么做。如何告诉Redis跟踪对数据库的调用并缓存其输出?我怎么知道它正在工作?


阅读 459

收藏
2020-06-20

共1个答案

小编典典

用伪代码:

see if redis has the record by 'record_type:record_id'
if so return the result
if not then query postgres for the record_id in the record_type table
store the result in redis by 'record_type:record_id'
return the result

这可能必须是您正在使用的查询引擎的自定义适配器。

2020-06-20