Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nickheppleston/787e3c1a4f893b09144e to your computer and use it in GitHub Desktop.
Azure Redis Cache - Cache StringGet/StringSet with Serialization/Deserialization to Custom .Net Type
var cacheItem = CacheSerializer.Deserialize<Guid>(cache.StringGet(cacheKey));
if (cacheItem == Guid.Empty)
{
// Cache item doesn't exist, retrieve Guid from source system.
// Add (serialized) Guid to the Azure Redis Cache with a lifespan of 90 minutes
cache.StringSet(cacheKey, CacheSerializer.Serialize(cacheItem), TimeSpan.FromMinutes(90));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment