Skip to content

Commit

Permalink
add prefix support for redis subscription set key
Browse files Browse the repository at this point in the history
  • Loading branch information
karen-stepanyan committed Sep 4, 2024
1 parent 2728460 commit 68c65a1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/util/subscription-set/subscription-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ export class SubscriptionSetFactory {
private redisClient?: Redis
private adapterName?: string
private capacity: AdapterSettings['SUBSCRIPTION_SET_MAX_ITEMS']
private cachePrefix: AdapterSettings['CACHE_PREFIX']

constructor(adapterSettings: AdapterSettings, adapterName: string, redisClient?: Redis) {
this.cacheType = adapterSettings.CACHE_TYPE
this.redisClient = redisClient
this.adapterName = adapterName
this.capacity = adapterSettings.SUBSCRIPTION_SET_MAX_ITEMS
this.cachePrefix = adapterSettings.CACHE_PREFIX
}

buildSet<T>(endpointName: string, transportName: string): SubscriptionSet<T> {
Expand All @@ -39,7 +41,8 @@ export class SubscriptionSetFactory {
throw new Error('Redis client undefined. Cannot create Redis subscription set')
}
// Identifier key used for the subscription set in redis
const subscriptionSetKey = `${this.adapterName}-${endpointName}-${transportName}-subscriptionSet`
const cachePrefix = this.cachePrefix ? `${this.cachePrefix}-` : ''
const subscriptionSetKey = `${cachePrefix}${this.adapterName}-${endpointName}-${transportName}-subscriptionSet`
return new RedisSubscriptionSet<T>(this.redisClient, subscriptionSetKey)
}
}
Expand Down

0 comments on commit 68c65a1

Please sign in to comment.