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?
The database index is the number you see at the end of a Redis URL: redis://localhost:6379/0 . The default database is 0 but you can change that to any number from 0-15 (and you can configure Redis to support more databases, look in redis.
Redis is an open-source, in-memory data structure store that is used to implement key-value databases and application caches.
To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With