在解析服务器上使用 Redis 进行缓存

Caching with Redis on a Parse Server

我在 2.6.3 解析服务器上,我需要缓存查询结果,以加快速度!

我知道 Parse Server 提供了一个 Redis 适配器。为了开始使用 Redis,我到底需要做什么?有没有我应该安装的模块?我应该导入或配置什么?

此外,我在 Parse 的文档中找到了这个:

Those cache adapters can be cleaned at anytime internally, you should not use them to cache data and you should let parse-server manage their data lifecycle.

他们说 you should not use them to cache data and you should let parse-server manage their data lifecycle. 是什么意思?我不应该使用适配器吗?

the doc 的意思是默认情况下使用它自己的内存结构解析缓存,但它让开发人员可以选择使用 reddis 作为替代。要选择它,只需 (1) 像往常一样设置 redis,(2) 使用已使用您的 redis URL.

配置的 RedisCacheAdapter 初始化解析服务器

您要问的要点:"you should not use them to cache data ..." 意味着 Parse 将继续决定何时缓存、何时从缓存中检索以及何时清理,等等,但它将通过调用您配置的 redis 来实现。

我认为这种更精细的设置的主要优势是 redis 的分布式能力。如果你不在集群上 运行,你可能会发现 redis 的想法在性能方面是等效的,但在设置方面有点混乱,因为不这样做。