refactor ContextCache
This commit is contained in:
parent
949e8ec5ea
commit
b495fa5ad0
|
@ -6,7 +6,7 @@ package xorm
|
||||||
|
|
||||||
// ContextCache is the interface that operates the cache data.
|
// ContextCache is the interface that operates the cache data.
|
||||||
type ContextCache interface {
|
type ContextCache interface {
|
||||||
// Put puts value into cache with key and expire time.
|
// Put puts value into cache with key.
|
||||||
Put(key string, val interface{})
|
Put(key string, val interface{})
|
||||||
// Get gets cached value by given key.
|
// Get gets cached value by given key.
|
||||||
Get(key string) interface{}
|
Get(key string) interface{}
|
||||||
|
@ -14,14 +14,17 @@ type ContextCache interface {
|
||||||
|
|
||||||
type memoryContextCache map[string]interface{}
|
type memoryContextCache map[string]interface{}
|
||||||
|
|
||||||
|
// NewMemoryContextCache return memoryContextCache
|
||||||
func NewMemoryContextCache() memoryContextCache {
|
func NewMemoryContextCache() memoryContextCache {
|
||||||
return make(map[string]interface{})
|
return make(map[string]interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put puts value into cache with key.
|
||||||
func (m memoryContextCache) Put(key string, val interface{}) {
|
func (m memoryContextCache) Put(key string, val interface{}) {
|
||||||
m[key] = val
|
m[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get gets cached value by given key.
|
||||||
func (m memoryContextCache) Get(key string) interface{} {
|
func (m memoryContextCache) Get(key string) interface{} {
|
||||||
return m[key]
|
return m[key]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue