2

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.

Mohammed H
  • 6,880
  • 16
  • 81
  • 127

1 Answers1

5

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

Thomas R.
  • 66
  • 2
  • It will be useful if you added any reference url. – Mohammed H Apr 23 '16 at 07:26
  • 1
    Since selective replication does not exist, [the documentation](http://redis.io/topics/replication) does not mention any of it, so there is nothing to reference. – Thomas R. Apr 23 '16 at 20:58