Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Delete(key string)
- func (c *Cache) Dispose()
- func (c *Cache) Expire(key string, duration time.Duration, handler func(key string, data interface{}))
- func (c *Cache) Get(key string) (val interface{}, ok bool)
- func (c *Cache) GetOrNew(key string, has func(ival interface{}), create func() interface{}) interface{}
- func (c *Cache) Set(key string, val interface{})
- func (c *Cache) SetExpiredSpace(t time.Duration)
- type Context
- type ICache
- type IContext
- type IContextRequest
- type RequestContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCacheSyncNoExpire ¶
func NewCacheSyncNoExpire() *Cache
func (*Cache) Expire ¶
func (c *Cache) Expire(key string, duration time.Duration, handler func(key string, data interface{}))
由于采用了标记的方式清楚expire, 所以可能会出现一种情况: 清理后, list中残留了一个键为[key]的expiredItem, 但后面只再次Set了[key]的值, 但没有Expire, 会导致expiredItem仍然生效 因此, 使用的时候需要注意这点
func (*Cache) GetOrNew ¶
func (c *Cache) GetOrNew(key string, has func(ival interface{}), create func() interface{}) interface{}
从cache中获取对象, 如果存在, 通过has方法进行处理; 如果不存在, 通过create方法创建, 接着调用has方法 该方法没有返回值
func (*Cache) SetExpiredSpace ¶
type IContextRequest ¶
type RequestContext ¶
type RequestContext struct { Context // contains filtered or unexported fields }
func NewRequestContext ¶
func NewRequestContext(ctx context.Context) (r *RequestContext)
func NewRequestContextDefault ¶
func NewRequestContextDefault() (r *RequestContext)
func (*RequestContext) GetCacheRequest ¶
func (ctx *RequestContext) GetCacheRequest() *Cache
Click to show internal directories.
Click to hide internal directories.