Documentation ¶
Index ¶
Constants ¶
View Source
const (
// NeverDie means value.alive() returns true forever.
NeverDie = 0
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a struct with caching functions.
func NewCacheWith ¶
NewCacheWith returns a new Cache holder with given options.
func (*Cache) AutoDump ¶
func (c *Cache) AutoDump()
AutoDump starts a goroutine and runs the dump task at fixed duration.
func (*Cache) AutoGc ¶
func (c *Cache) AutoGc()
AutoGc starts a goroutine and runs the gc task at fixed duration.
func (*Cache) SetWithTTL ¶
SetWithTTL sets an entry of specified key and value which has ttl.
type Options ¶
type Options struct { // MaxEntrySize is the max memory size that entries can use. // The unit is GB. MaxEntrySize int // MaxGcCount is the max count of entries that gc will clean. MaxGcCount int // GcDuration is the duration between two gc tasks. // The unit is Minute. GcDuration int // DumpFile is the file used to dump the cache. DumpFile string // DumpDuration is the duration between two dump tasks. // The unit is Minute. DumpDuration int // MapSizeOfSegment is the map size of segment. MapSizeOfSegment int // SegmentSize is the number of segment in a cache. // This value should be the pow of 2 for precision. SegmentSize int // CasSleepTime is the time of sleep in one cas step. // The unit is Microsecond. CasSleepTime int }
Options is the struct of options.
Click to show internal directories.
Click to hide internal directories.