Documentation
¶
Index ¶
- type Builder
- type Loader
- type LocalCache
- func (cache *LocalCache) Delete(key interface{})
- func (cache *LocalCache) Get(key interface{}) (interface{}, error)
- func (cache *LocalCache) GetIfPresent(key interface{}) interface{}
- func (cache *LocalCache) Put(key, value interface{})
- func (cache *LocalCache) Range(f func(key, value interface{}) bool)
- type Mutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder() *Builder
func (*Builder) Build ¶
func (builder *Builder) Build(loader Loader) *LocalCache
func (*Builder) ExpireAfterAccess ¶
type LocalCache ¶
type LocalCache struct {
// contains filtered or unexported fields
}
1. 空间换时间。 通过冗余的两个数据结构(read、dirty),减少加锁对性能的影响。 2. 使用只读数据(read),避免读写冲突。 3. 动态调整,miss次数多了之后,将dirty数据提升为read。 4. double-checking。 5. 延迟删除。 删除一个键值只是打标记,只有在提升dirty的时候才清理删除的数据。 6. 优先从read读取、更新、删除,因为对read的读取不需要锁。
func (*LocalCache) Delete ¶
func (cache *LocalCache) Delete(key interface{})
func (*LocalCache) Get ¶
func (cache *LocalCache) Get(key interface{}) (interface{}, error)
func (*LocalCache) GetIfPresent ¶
func (cache *LocalCache) GetIfPresent(key interface{}) interface{}
func (*LocalCache) Put ¶
func (cache *LocalCache) Put(key, value interface{})
func (*LocalCache) Range ¶
func (cache *LocalCache) Range(f func(key, value interface{}) bool)
Click to show internal directories.
Click to hide internal directories.