improve adapter feature for package gcache

This commit is contained in:
John
2020-09-26 22:44:07 +08:00
parent bae8f6315b
commit aeb9b68298
3 changed files with 25 additions and 8 deletions

View File

@ -38,6 +38,11 @@ func (c *Cache) SetAdapter(adapter Adapter) {
c.Adapter = adapter
}
// Contains returns true if <key> exists in the cache, or else returns false.
func (c *Cache) Contains(key interface{}) bool {
return c.Get(key) != nil
}
// GetVar retrieves and returns the value of <key> as gvar.Var.
func (c *Cache) GetVar(key interface{}) *gvar.Var {
return gvar.New(c.Get(key))