Last active
August 29, 2015 14:07
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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