Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/database/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ export class RedisDatabase implements DatabaseDriver {
*/
private _redis: any;

/**
*
* KeyPrefix for used in the redis Connection
*
* @type {String}
*/
private _keyPrefix: string;

/**
* Create a new cache instance.
*/
constructor(private options) {
this._keyPrefix = options.databaseConfig.redis.keyPrefix || '';
this._redis = new Redis(options.databaseConfig.redis);
}

Expand All @@ -29,7 +38,7 @@ export class RedisDatabase implements DatabaseDriver {
set(key: string, value: any): void {
this._redis.set(key, JSON.stringify(value));
if (this.options.databaseConfig.publishPresence === true && /^presence-.*:members$/.test(key)) {
this._redis.publish('PresenceChannelUpdated', JSON.stringify({
this._redis.publish(`${this._keyPrefix}PresenceChannelUpdated`, JSON.stringify({
"event": {
"channel": key,
"members": value
Expand Down
3 changes: 3 additions & 0 deletions src/subscribers/redis-subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export class RedisSubscriber implements Subscriber {

return new Promise((resolve, reject) => {
this._redis.on('pmessage', (subscribed, channel, message) => {
if (channel.endsWith('PresenceChannelUpdated')) {
return;
}
try {
message = JSON.parse(message);

Expand Down