Mohammed H
Mohammed H

Reputation: 7058

Redis replication at key level

We are using redis. We have two set of data. One set of data(Assume it is using the prefix redis:local: eg: redis:local:key1) is used by the main application and no need of replication.

Another set of data (Prefix redis:replicate: eg: redis:replicate:key2) is used by the main application and should be replicated to slave redis instances.

I have two questions.

  1. Is it possible to configure redis to replicate only keys with prefix redis:replicate:?

  2. If that is not possible, Is it possible to configure redis to replicate only one database? We will store the first set of data in database-0 and the second set of data in database-1. So we have to replicate only database-1.

Currenly, we are running two instances of redis to solve the issue.

Upvotes: 2

Views: 1596

Answers (1)

Thomas R.
Thomas R.

Reputation: 66

Redis only supports replication of whole instances. Limiting replication to a key prefix or database is not possible.

Running two instances of Redis is simplest and reliable option. Another way would be to write a custom replication program which is difficult and failure prone in comparison.

There is also another question concerning replication of only one database: Replicate a single Redis database from an instance that has multiple databases

Upvotes: 5

Related Questions