在redis:// localhost:6379/0/cache中0/cache的含义是什么

Pra*_*tki 2 ruby-on-rails redis

在Rails应用程序中添加redis作为我的缓存存储时,

我添加了redis网址redis://localhost:6379/0/cache.

0/cache在redis URL中是什么意思?

Laz*_*dis 9

您可以将redis配置为使用许多数据库.

0意味着你使用第一个(id = 0).
cache是数据库的命名空间.

根据您设置此URL的位置,您实际上是在告诉使用redis缓存,并且将从数据库0和命名空间中保存/检索值等cache.

  • 再告诉我一件事。默认有多少个数据库? (4认同)
  • 我用 redis-rails (redis-store for Rails) 对此进行了测试,并且没有“缓存”命名空间。我必须通过命名空间选项设置命名空间,如下所示: `config.cache_store = :redis_store, 'redis://localhost:6379/0', { expires_in: 60.minutes, namespace: "#{Rails.env}:缓存”}` (2认同)