Alberto Cassinari
Alberto Cassinari

Reputation: 31

Setup parse and redis for live queries

I have a parse server running in clustering, everything works perfectly but in the last days I have had to add live queries, just activate it in the configuration doesn't work very well, because the event "create" is triggered only few times (while not in clustering it doesn't miss one). From parse documentation it's suggested to use redis, and here is my problem: I don't understand how the parse's db is passed to redis' db to work properly. Could please someone just put me on right path?

Upvotes: 1

Views: 739

Answers (1)

nathan
nathan

Reputation: 9395

When you configure your ParseServer, there's an option to include the URL for the Redis server and set the class names for which you want to enable Live Queries:

liveQuery: {
    classNames: ['_User', 'Map'],
    redisURL: 'redis://localhost:6379'  
}

Full setup:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://IP:PORT/PATH',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'AppID',
  masterKey: process.env.MASTER_KEY || 'MasterKey', //Add your master key here. Keep it secret!
  //javascriptKey: process.env.JAVASCRIPT_KEY || '',
  serverURL: process.env.SERVER_URL || 'http://IP:PORT/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ['ExampleClass'], // Add Class names here
    redisURL: 'redis://REDIS_IP:REDIS_PORT'
  },
});
var app = express();


var port = process.env.PORT || 1111;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('App on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer,  {
  redisURL: 'redis://REDIS_IP:REDIS_PORT'
});

Upvotes: 1

Related Questions