8

While adding redis as my cache store in Rails app,

i added the redis url as redis://localhost:6379/0/cache.

What is the meaning of 0/cache in the redis URL?

1 Answers1

15

You may configure redis to use many databases.

The 0 means you are using the first of them (id=0).
The cache is the namespace of the database.

Depending on where you set this url, you are actually telling to use redis caching and values will be saved/retrieved etc from the database 0 and namespace cache.

Lazarus Lazaridis
  • 5,803
  • 2
  • 21
  • 35
  • 4
    Tell me one more thing. How many databases are there exist by default? – sagar junnarkar Dec 26 '13 at 06:38
  • 1
    I tested this with redis-rails (redis-store for Rails), and there's no 'cache' namespace. I had to set a namespace through the namespace option like so: `config.cache_store = :redis_store, 'redis://localhost:6379/0', { expires_in: 60.minutes, namespace: "#{Rails.env}:cache" }` – Sebastiaan Pouyet May 02 '14 at 08:34