Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound will be returned when getting a key that not setting before. ErrNotFound = errors.New("not found") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a LRU filesystem cache based on atime.
type Interface ¶
type Interface interface { // Set sets the value of key as src. // Setting the same key multiple times, the last set call takes effect. Set(key string, src []byte) error // Get gets the value of key to dst, and returns dst no matter whether or not there is an error. Get(key string, dst []byte) ([]byte, error) // Has tells you if a key has been set or not. Has(key string) bool }
Interface provides a set of general cache functions.
type Logger ¶
type Logger interface {
Errorf(fmt string, args ...interface{})
}
Logger used by this package.
type Option ¶
type Option func(fc *Cache)
Option can be passed to New() to tailor your needs.
func WithCacheDir ¶
WithCacheDir specifies where the cache holds.
func WithGcInterval ¶
WithGcInterval specifies how often the GC performs.
func WithGcStopCh ¶
func WithGcStopCh(stopCh <-chan struct{}) Option
WithGcStopCh receives a channel, when the channel close, gc will stop. By default, gc will not stop until the process exits.
func WithMaxBytes ¶
WithMaxBytes specifies how many space the cache could take up.
Click to show internal directories.
Click to hide internal directories.