A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/StackExchange/StackExchange.Redis/issues/2507 below:

Can't consume bulk keys from Invalidate channel · Issue #2507 · StackExchange/StackExchange.Redis · GitHub

Hi.

To implement client-side caching, I have subscribed to "redis:invalidate" channel in my application as described in the article, and the application can consume invalidated messages successfully when another connection updates a key. Below is how my application connects to channel:

IConnectionMultiplexer _connection; //Initialized at startup. 
RedisChannel _invalidationChannel = new("__redis__:invalidate", RedisChannel.PatternMode.Auto);
ISubscriber subscriber = _connection.GetSubscriber()
subscriber.Subscribe(_invalidationChannel)?.OnMessage(OnMessage);
_connectionFacade.Execute("CLIENT", "TRACKING", "on", "REDIRECT", connectionId, "BCAST", "NOLOOP");

private void OnMessage(ChannelMessage message)
{
    try
    {
        _logger.LogDebug(message.Message.ToString());
    }
    catch(Exception ex)
    {
        _logger.LogError(ex, "Error RedisInvalidator.OnMessage: {message}", ex.Message);
    }
}

However, if I use bulk commands like MSET, MDEL or transactional update from another application with multiple variables, StackExchange.Redis doesn't consume any invalidation messages. Redis server is able to send a single invalidation message for multiple keys, which I tested by subscribing by terminal. If I apply MSET command with one key-value pair, I can consume it in the application however if I apply it with multiple key-value pairs then I can't consume it. Also no exceptions are thrown from the library.

As shown in below, for testing purposes I opened two terminals, left one was listening the invalidation channel, and right one was updating the Redis. First, I applied "MSET test 123"(right terminal) and this one is consumed by left-hand terminal and by my application as well. However when I applied "MSET test 123 test2 123"(right terminal), it was only consumed by left-hand terminal. My application couldn't consume it. Be aware that invalidation message consist list of keys that are invalidated when there is a multiple invalidation.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4