public void Subscribe() { if (!ConfigurationVerifier .TryVerifyConfiguration( "notify-keyspace-events", out var keyeventNotificationsException, "g", "h", "E")) { Logger?.LogWarning( keyeventNotificationsException, "Failed to verify keyevent notifications config."); } Subscriber.Value.Subscribe( "__keyevent@*__:del", (channel, message) => { if (message.StartsWith( L1L2RedisCacheOptions.KeyPrefix)) { var key = message .ToString()[L1L2RedisCacheOptions.KeyPrefix.Length..]; L1Cache.Remove( $"{L1L2RedisCacheOptions.KeyPrefix}{key}"); L1Cache.Remove( $"{L1L2RedisCacheOptions.LockKeyPrefix}{key}"); }
public void Subscribe() { if (!ConfigurationVerifier .TryVerifyConfiguration( "notify-keyspace-events", out var keyeventNotificationsException, "g", "h", "K")) { Logger?.LogWarning( keyeventNotificationsException, "Failed to verify keyspace notifications config."); } Subscriber.Value.Subscribe( "__keyspace@*__:*", (channel, message) => { if (message == "del" || message == "hset") { var keyPrefixIndex = channel.ToString().IndexOf( L1L2RedisCacheOptions.KeyPrefix); if (keyPrefixIndex != -1) { var key = channel.ToString()[ (keyPrefixIndex + L1L2RedisCacheOptions.KeyPrefix.Length)..]; L1Cache.Remove( $"{L1L2RedisCacheOptions.KeyPrefix}{key}"); L1Cache.Remove( $"{L1L2RedisCacheOptions.LockKeyPrefix}{key}"); }