Skip to content

Instantly share code, notes, and snippets.

@kblok
Created June 22, 2020 16:34
Show Gist options
  • Select an option

  • Save kblok/98dbfecdc27e9332601fce6554256ef1 to your computer and use it in GitHub Desktop.

Select an option

Save kblok/98dbfecdc27e9332601fce6554256ef1 to your computer and use it in GitHub Desktop.
SetContentWithInvalidationIndexes
public Task SetContentAsync(string key, string value, TimeSpan? timespan, IEnumerable<string> invalidationIndexes, int database, ConnectionMultiplexer redisConn)
{
redisConn = redisConn ?? ConnectionHelper.Connection;
var cache = redisConn.GetDatabase(database);
var tasks = invalidationIndexes.Select(ix => cache.SetAddAsync(ix, key)).ToList();
tasks.Add(cache.StringSetAsync(key.ToLower(), value, expiry: timespan));
return Task.WhenAll(tasks);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment