Add, retrieve and remove complex object
Create your instance:
var user = new User()
{
Username = "imperugo",
Firstname = "Ugo",
Lastname = "Lattanzi",
Twitter = "@imperugo"
Blog = "http://tostring.it",
Company = new Company
{
Name = "My Super Company",
Vat = "IT12345678911",
Address = "somewhere road 12"
}
}
Add object to Redis
bool added = await cacheClient.Db0.AddAsync("my cache key", user, DateTimeOffset.Now.AddMinutes(10));
Retrieve the object:
var userFromCache = await cacheClient.Db0.GetAsync<User>("my cache key");
Remove and object
bool removed = await cacheClient.Db0.RemoveAsync<User>("my cache key");
Last updated
Was this helpful?