Redis + CacheAdapter + LiveQuery

Hi All,

I’m a bit confused on Redis and its configuration.

General Questions
Based on documentation, there is:

  1. a field for ‘cacheAdapter’ in the parse server configuration
  2. a field ‘redisURL’ under the liveQuery configuration
  3. a ‘redisURL’ within the createLiveQueryServer configuration.

Do you use the same Redis URL for all three of these, or is the livequery redis supposed to be different the the cache Adapter?

My Setup Question

  1. I’m using AWS
  2. I’m using elasticCache redis

If the two redis urls are different, do you need 2 instances of elastic cache redis or use the same instance?

If it’s the same instance, i know the documentation specifies a different DB but how do I set that within the configuration to work with AWS Elastic Cache.

I have the redis cache adapter setup and working, but its just very unclear how to add in the redis for live query and verify that it is caching correctly.

I’m not expert on this. But documentation page says redis for live query must be different from cache adapter.

I believe second and third option is same. You should pass same redis instance. And I dont think you should pass redis to both. Setting redis to one of them(among 2 and 3) should be enough. But I’m not sure.

Edit: Setting redis to only one of them doesnt work. I just tried it. You need to pass redis url to both parse server configuration and live query command like this:

liveQuery: {
    classNames: ['Message'],
    redisURL: 'redis://aaa:[email protected]:6379'


  redisURL: 'redis://aaa:[email protected]:6379'

If one of them is not set, LiveQuery doesnt work.

I think the documentation is a little confusing. Are you willing to open a PR to improve it?

Here’s an example of how I use it:

Parse Sever:

const redisOptions = {url: process.env.PARSE_SERVER_REDIS_URL, db: process.env.PARSE_SERVER_REDIS_DB}
const redisCache = new RedisCacheAdapter(redisOptions);

const api = new ParseServer({
  cacheAdapter: redisCache,
  liveQuery: {
    classNames: ["Clock", ...],
    redisURL: process.env.PARSE_SERVER_REDIS_URL,
    redisOptions: { socket_keepalive: true, db: process.env.PARSE_LIVEQUERY_SERVER_REDIS_DB},

LiveQuery Server

const config = {
  masterKey: process.env.PARSE_SERVER_MASTER_KEY,
  keyPairs: {
    masterKey: process.env.PARSE_SERVER_MASTER_KEY
  serverURL: process.env.PARSE_SERVER_URL,
  websocketTimeout: 10 * 1000,
  cacheTimeout: 60 * 600 * 1000,
  logLevel: 'VERBOSE',
  redisURL: process.env.PARSE_SERVER_REDIS_URL,
  redisOptions: {db: process.env.PARSE_LIVEQUERY_SERVER_REDIS_DB, socket_keepalive: true}

// This will enable the Live Query real-time server
const parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer, config);

In my case, the redis URLs are the same, but the Server and LiverQuery Server Redis DB’s are different

This is a question I’ve been meaning to get an answer to for a while.

LiveQuery uses redis for pub/sub only. Does pub/sub store anything in the redis? I don’t believe so. Since it doesn’t store anything I think it should be perfectly fine to use the same redis for both. Don’t quote me on this. The documentation was writing a long time ago and isn’t clear.

A quick search

Database & Scoping

Pub/Sub has no relation to the key space. It was made to not interfere with it on any level, including database numbers.

Publishing on db 10, will be heard by a subscriber on db 1.

1 Like

Thank you very much. This was exactly what I was looking for!

Link me to where to create the pull request and I’ll try to spend some time improving the instructions.

1 Like

Great information, Thanks! Redis is new to me and this provides some context aroud how it is used with LiveQuery.

You should be able to edit and create the PR here: docs/ at gh-pages · parse-community/docs · GitHub