Documentation
¶
Overview ¶
Package objcache implements in memory caching methods.
Package objcache implements in memory caching methods.
Index ¶
Constants ¶
Variables ¶
var ( // ErrKeyNotFoundInCache - key not found in cache. ErrKeyNotFoundInCache = errors.New("Key not found in cache") // ErrCacheFull - cache is full. ErrCacheFull = errors.New("Not enough space in cache") // ErrExcessData - excess data was attempted to be written on cache. ErrExcessData = errors.New("Attempted excess write on cache") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { // OnEviction - callback function for eviction OnEviction func(key string) // contains filtered or unexported fields }
Cache holds the required variables to compose an in memory cache system which also provides expiring key mechanism and also maxSize.
func New ¶
New - Return a new cache with a given default expiry duration. If the expiry duration is less than one (or NoExpiry), the items in the cache never expire (by default), and must be deleted manually.
func (*Cache) Create ¶
Create - validates if object size fits with in cache size limit and returns a io.WriteCloser to which object contents can be written and finally Close()'d. During Close() we checks if the amount of data written is equal to the size of the object, in which case it saves the contents to object cache.
func (*Cache) Open ¶
Open - open the in-memory file, returns an in memory read seeker. returns an error ErrNotFoundInCache, if the key does not exist. Returns ErrKeyNotFoundInCache if entry's lastAccessedTime is older than objModTime.