# Work with multiple items

If you need to add, remove or retrieve more than one item you don't have to send multiple requests into Redis. This library offers few methods that allow you to use a single command in order to do that increasing the performances because there is only one roundtrip from your app to the Redis server.

You instance:

```javascript
var user1 = 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"
	}
}

var user2 = new User()
{
	Username = "mario.rossi",
	Firstname = "Mario",
	Lastname = "Rossi",
	Twitter = "@mariorossi"
	Blog = "http://imperugo.tostring.it/",
	Company = new Company 
	{
		Name = "My Super Company",
		Vat = "IT12345678911",
		Address = "somewhere road 12"
	}
}
```

Add multiple items:

```javascript
var items = new List<Tuple<string, User>>();
items.Add(new Tuple<string, User>("key1", user1));
items.Add(new Tuple<string, User>("key2", user2));

bool added = await cacheClient
                .Db0
                .AddAllAsync(items, DateTimeOffset.Now.AddMinutes(10));
```

Remove multiple items:

```javascript
var numberOfItemRemoved = await cacheClient
                                .Db0
                                .RemoveAllAsync(new []{"key1","key2"});
```

Retrieve multiple items:

```javascript
var users = await cacheClient
                                .Db0
                                .GetAllAsync<User>(new []{"key1","key2"});
```

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://imperugo.gitbook.io/stackexchange-redis-extensions/usage/work-with-multiple-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
