StackExchange Redis Keys and Values

From WikiOD

Setting Values[edit | edit source]

All values in Redis are ultimately stored as a RedisValue type:

//"myvalue" here is implicitly converted to a RedisValue type
//The RedisValue type is rarely seen in practice.
db.StringSet("key", "aValue");

Setting and getting an int[edit | edit source]

db.StringSet("key", 11021);
int i = (int)db.StringGet("key");

Or using StackExchange.Redis.Extensions:

db.Add("key", 11021);
int i = db.Get<int>("key");

This article is an extract of the original Stack Overflow Documentation created by contributors and released under CC BY-SA 3.0. This website is not affiliated with Stack Overflow