Documentation ¶
Index ¶
- Constants
- Variables
- func ExpireRevisitFunc(cache hafezieh.Cache, key string, item *InMemItem)
- func NewMemoryCache(config *InMemoryCacheConfig) (hafezieh.Cache, error)
- type CleanupFunc
- type CleanupMechanism
- type InMemItem
- type InMemKey
- type InMemoryCache
- type InMemoryCacheConfig
- type InMemoryCleanupConfig
- type RevisitFunc
Constants ¶
View Source
const ( // CleanupNone means no cleanup CleanupNone CleanupMechanism = iota // CleanupCustomFunc calls the set custom function to cleanup the memory CleanupCustomFunc = iota // CleanupHeapBasedLRU checks the current HeapAlloc, and if it's higher // than the CleanupHeapTarget, CleanupPercent% of the least recently used // items will be deleted CleanupHeapBasedLRU = iota // CleanupNumberBasedLRU checks the current number of items, and if it's // higher than the CleanupNumberOfItemsTarget, the least recently used // items will be deleted so the number of items became (nearly) equal to // CleanupNumberOfItemsTarget CleanupNumberBasedLRU = iota )
Variables ¶
View Source
var (
ErrSmallDuration = errors.New("less than 5 seconds isn't supported by this engine")
)
Functions ¶
func NewMemoryCache ¶
func NewMemoryCache(config *InMemoryCacheConfig) (hafezieh.Cache, error)
Types ¶
type CleanupFunc ¶
type CleanupFunc func(*InMemoryCache)
type CleanupMechanism ¶
type CleanupMechanism uint8
type InMemoryCache ¶
type InMemoryCache struct {
// contains filtered or unexported fields
}
func (*InMemoryCache) Close ¶
func (c *InMemoryCache) Close() error
func (*InMemoryCache) Del ¶
func (c *InMemoryCache) Del(key string) error
func (*InMemoryCache) Get ¶
func (c *InMemoryCache) Get(key string) (interface{}, error)
type InMemoryCacheConfig ¶
type InMemoryCacheConfig struct { RevisitDefaultDuration time.Duration `mapstructure:"revisit-default-duration"` RevisitNumberOfWorkers int `mapstructure:"revisit-number-of-workers"` RevisitClock time.Duration `mapstructure:"revisit-clock"` RevisitFunc RevisitFunc Cleanup *InMemoryCleanupConfig `mapstructure:"cleanup"` }
type InMemoryCleanupConfig ¶
type InMemoryCleanupConfig struct { Mechanism CleanupMechanism `mapstructure:"mechanism"` Clock time.Duration `mapstructure:"clock"` HeapTarget uint64 `mapstructure:"heap-target"` NumberOfItemsTarget uint64 `mapstructure:"number-target"` Percent float64 `mapstructure:"percent"` CustomFunc CleanupFunc }
Click to show internal directories.
Click to hide internal directories.