getMultipleItems function added! (issue #108)

This commit is contained in:
Mobinapournemat 2021-02-08 00:05:17 +03:30
parent 46f4078530
commit 3d7b9b7922
1 changed files with 11 additions and 0 deletions

View File

@ -135,6 +135,17 @@ func (c *cache) Get(k string) (interface{}, bool) {
return item.Object, true
}
//GetMultipleItems returns an array of items corresponding to the input array
func (c *cache) GetMultipleItems(values []string) []interface{} {
length := len(values)
var items = make([]interface{}, length)
for i := 0; i < length; i++ {
item, _ := c.Get(values[i])
items[i] = item
}
return items
}
// GetWithExpiration returns an item and its expiration time from the cache.
// It returns the item or nil, the expiration time if one is set (if the item
// never expires a zero value for time.Time is returned), and a bool indicating