Recently I have been playing around with Redis. In particular I have been trying how to integrate Redis with web services in Azure.
Redis is actually more like a data structures server, supporting very interesting data structures, and operations on them.
I am listing down some data structures, and corresponding when using these data structures.
- Strings
- Lists
- Sets
- Sorted Sets
- Useful when fast access to the middle of a large collection of elements is important
- Hashes
- Hashes are maps between string fields and string values, so they are the perfect data type to represent objects.
- Bit arrays
- Hyper Log Log
DECR, DECRBY, DEL, EXISTS, EXPIRE, GET, GETSET, HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HKEYS, HLEN, HMGET, HMSET, HSET, HVALS, INCR, INCRBY, KEYS, LINDEX, LLEN, LPOP, LPUSH,LRANGE, LREM, LSET, LTRIM, MGET, MSET, MSETNX, MULTI, PEXPIRE, RENAME, RENAMENX, RPOP, RPOPLPUSH, RPUSH, SADD, SCARD, SDIFF, SDIFFSTORE, SET, SETEX, SETNX, SINTER, SINTERSTORE, SISMEMBER, SMEMBERS, SMOVE, SORT, SPOP, SRANDMEMBER, SREM, SUNION, SUNIONSTORE, TTL, TYPE, ZADD,ZCARD, ZCOUNT, ZINCRBY, ZRANGE, ZRANGEBYSCORE, ZRANK, ZREM, ZREMRANGEBYSCORE, ZREVRANGE, ZSCORE
Code on GitHub:
References:
- Getting Started using Redis on Azure:
- Redis GUIs
- Good post on use of Redis for .NET
- Redis Commands
- Good reference to understand how Redis works and what StackExchage.Redis does under the table.
- StackExchage.Redis
- Documentation is helpful if you choose this library as your wrapper.
- StackExchange.Redis.Extensions
- Good library that wraps the common operation needed with StackExchange.Redis (eliminates need to serialize objects or create helpers as shown in code above)
- Add complex objects to Redis
- Remove an object from Redis;
- Search Keys into Redis;
- Retrieve multiple objects with a single roundtrip;
- Store multiple objects with a single roundtrip;
- Async methods;
- Retrieve Redis Server status;
- Much more;
- It uses Json.Net (NewtonSoft), Jil or Message Pack CLI to serialize objects into a
byte[]
.