-
Change all db to connection.GetDb()
-
Topics
- Strings
- Object as json strings
- HashMap
- List
- listening to list
- Set
- pub/sub
- Understand
RedisValue
- lua script
- transactional updates
- Connections and configurations
- Explain multiplexer vs getDatabase(), cheap pass thorugh and reusable
-
Cookbook
- Consensus building
- Work distribution
-
Best practices
- Wrap IDatabase (for testing/mocking)
- Create only one multiplexer
-
Advanced
- SSL with redis
- mastter slave
- kyspace notifications
-
Create a client
-
Use
SETENX
-
Save a POCO by its id in redis
-
Retrieve a POCO by its id in redis
-
Implement connection recovery
-
Use Docker to run Redis and Redis CLI on your machine
-
Choose a client library and create a .NET console app
-
Save strings. learn TTL for key expiry, and using NX for writting only when value is null
-
Storing Objects As Json Strings
Create extensions to build custom logic like serializing/deserializing objects to store them as JSON in Redis.
-
Use Entries to save and get Maps. APIs to update/read individual fields in Map.
-
Blocking pop is not supported in Stackexchange.Redis.
Misc
- redis treats a non-existent key as zero;
- nil responses are treated as zero
- Keys can be string or byte (redis never tries to interpret them as any type)
- Use
KeyValue.HasValue
to check if there is any value for the key
-
Read basics about redis:
-
Ensure .NET6 is installed
-
Ensure docker is installed ( v3.3.1 or above)
Download and install from https://www.docker.com/products/docker-desktop.
-
CLI
Commands in this arcticle are created for bash. You can use most command in a poweshell. Its recommended to use something like
wsl
orgit bash
if you are running on windows.Download and install gitbash (if required) from : https://git-scm.com/downloads
-
Redis c# clients: https://docs.redis.com/latest/rs/references/client_references/client_csharp/
-
StackExchangeRedis: https://github.com/StackExchange/StackExchange.Redis
-
StackExchangeRedis Docs: https://stackexchange.github.io/StackExchange.Redis/
-
StackExchangeRedis Best Practices : https://gist.github.com/JonCole/925630df72be1351b21440625ff2671f#stackexchangeredis