我有一个在集群中运行的解析服务器,一切正常,但在过去的几天里,我不得不添加实时查询,只是在配置中激活它效果不佳,因为事件“创建”仅被触发几次(虽然不在集群中,但它不会错过任何一次)。 从解析文档中建议使用 redis,这是我的问题:我不明白如何将解析的数据库传递给 redis 的数据库以正常工作。 可以请有人让我走上正确的道路吗?
最佳答案
当您配置 ParseServer 时,有一个选项可以包含 Redis 服务器的 URL 并设置您要为其启用实时查询的类名:
liveQuery: {
classNames: ['_User', 'Map'],
redisURL: 'redis://localhost:6379'
}
完整设置:
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'
});
关于parse-platform - 为实时查询设置解析和 redis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44550397/