Azure Redis Cache
Shahriar Hossain
Microsoft MVP
@shossain_tweet
Caching ?
Caching
• Temporarily copying frequently accessed data to fast storage that's
located closeto the application.
• Use for Increase performanceand Increase availability.
What is Redis ?
• Redis is an open-source in-memorydata structure project implementing a
distributed, in-memory key-value database with optional
durability which used as a database, cacheand message broker
• REDIS=REmote Dictonary Server
Azure Redis Cache
• Azure Redis Cache = Redis + Auth + SSL
• Azure PAAS
• Monitoring
• Alert
• Azure Eco system friendly
In Memory = No Persistence
• AOF (Append only Files)
• RDB (Redis DB Snapshots)
Establishing connection with Azure Redis
• Step 1: Install-Package StackExchange.Redis
• Step 2: Set connection string
• Step 3: ConnectionMultiplexer class should be shared & resued & laze loaded.
Establishing connection with Azure Redis
• Step 4: Call the GetDatabase() of Connection property.
• Step 5 : Use Json.Net serializer for complex object.
Pattern to Consider
Use this pattern if :
a. Cache doesn't provide native read-
through and write-through operations.
b. Resource demand is unpredictable.
c. Read heavy workload.
DONT USE if:
a) Cached data set is static.
b) Caching session state information in a
web application hosted in a web farm
Cache Invalidation
private const double DefaultExpiration = 5.0;
cache.KeyExpireAsync(key, TimeSpan.FromMinutes(DefaultExpiration))
What happened to my data?
• Some of my keys have disappeared !
• Expiration [ SET, PSETX, EXPIRE]
• Eviction [LRU cache rule]
• Key Deletion [DEL, HDEL]
• Async Replication
• Most or All my keys are gone !!
• Single Node Configuration [example: Azure Basic Tier]
• Flush [FLUSHDB, FLUSHALL]
• Multi-node failure
Scaling Redis
1. https://redislabs.com/ebook/pa
rt-3-next-steps/chapter-10-
scaling-redis/
2. https://docs.microsoft.com/en-
us/azure/azure-cache-for-
redis/cache-how-to-scale
Resource
• https://www.openmymind.net/redis.pdf
DEMO/LAB
Questions ?
Microsoft Azure Bangladesh
group: www.facebook.com/groups/microsoft.azure.bd
fan page: fb.com/microsoft.azure.bd
Asp.Net - Bangladesh
www.facebook.com/groups/asp.net.mvc.bd
Community Group
Shahriar Hossain
Facebook
Personal Blog
LinkedIn
http://LearnWithShahriar.wordpress.com
Thank You

Azure redis cache