@@ -126,6 +126,65 @@ describe('RedisGroupNotificationPublisher', () => {
126126 await notificationPublisher1 . close ( )
127127 } )
128128
129+ it ( 'Propagates invalidation event to remote cache, works with redis config' , async ( ) => {
130+ const { publisher : notificationPublisher1 , consumer : notificationConsumer1 } =
131+ createGroupNotificationPair ( {
132+ channel : CHANNEL_ID ,
133+ consumerRedis : redisOptions ,
134+ publisherRedis : redisOptions ,
135+ } )
136+
137+ const { publisher : notificationPublisher2 , consumer : notificationConsumer2 } =
138+ createGroupNotificationPair ( {
139+ channel : CHANNEL_ID ,
140+ consumerRedis : redisConsumer ,
141+ publisherRedis : redisPublisher ,
142+ } )
143+ const operation = new GroupLoader ( {
144+ inMemoryCache : IN_MEMORY_CACHE_CONFIG ,
145+ asyncCache : new DummyGroupedCache ( userValues ) ,
146+ notificationConsumer : notificationConsumer1 ,
147+ notificationPublisher : notificationPublisher1 ,
148+ } )
149+
150+ const operation2 = new GroupLoader ( {
151+ inMemoryCache : IN_MEMORY_CACHE_CONFIG ,
152+ asyncCache : new DummyGroupedCache ( userValues ) ,
153+ notificationConsumer : notificationConsumer2 ,
154+ notificationPublisher : notificationPublisher2 ,
155+ } )
156+ await operation . init ( )
157+ await operation2 . init ( )
158+
159+ await operation . getAsyncOnly ( 'key' , 'group' )
160+ await operation2 . getAsyncOnly ( 'key' , 'group' )
161+ const resultPre1 = operation . getInMemoryOnly ( 'key' , 'group' )
162+ const resultPre2 = operation2 . getInMemoryOnly ( 'key' , 'group' )
163+ await operation . invalidateCacheFor ( 'key' , 'group' )
164+
165+ await waitAndRetry (
166+ ( ) => {
167+ const resultPost1 = operation . getInMemoryOnly ( 'key' , 'group' )
168+ const resultPost2 = operation2 . getInMemoryOnly ( 'key' , 'group' )
169+ return resultPost1 === undefined && resultPost2 === undefined
170+ } ,
171+ 50 ,
172+ 100 ,
173+ )
174+
175+ const resultPost1 = operation . getInMemoryOnly ( 'key' , 'group' )
176+ const resultPost2 = operation2 . getInMemoryOnly ( 'key' , 'group' )
177+
178+ expect ( resultPre1 ) . toEqual ( user1 )
179+ expect ( resultPre2 ) . toEqual ( user1 )
180+
181+ expect ( resultPost1 ) . toBeUndefined ( )
182+ expect ( resultPost2 ) . toBeUndefined ( )
183+
184+ await notificationConsumer1 . close ( )
185+ await notificationPublisher1 . close ( )
186+ } )
187+
129188 it ( 'Propagates delete group event to remote cache' , async ( ) => {
130189 const { publisher : notificationPublisher1 , consumer : notificationConsumer1 } =
131190 createGroupNotificationPair ( {
0 commit comments