> For the complete documentation index, see [llms.txt](https://imperugo.gitbook.io/stackexchange-redis-extensions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://imperugo.gitbook.io/stackexchange-redis-extensions/usage/add-and-retrieve-complex-object-to-redis.md).

# Add, retrieve and remove complex object

Create your instance:

```javascript
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

```javascript
bool added = await cacheClient.Db0.AddAsync("my cache key", user, DateTimeOffset.Now.AddMinutes(10));
```

Retrieve the object:

```javascript
var userFromCache = await cacheClient.Db0.GetAsync<User>("my cache key");
```

{% hint style="info" %}
Note that is possible to change the expires time of the item also when you are retrieving it. In fact the method GetAsync offers two overloads that accept DateTimeOffset or TimeSpan in order to change the expiration time of the item without submit it again.
{% endhint %}

Remove and object

```javascript
bool removed = await cacheClient.Db0.RemoveAsync<User>("my cache key");
```
