Documentation ¶
Index ¶
- type ExceedsLengthError
- type InsufficientLengthError
- type Item
- type KeyCache
- func (k *KeyCache) Add(objectStoreKey string, item Item) (bool, error)
- func (k *KeyCache) Delete(objectStoreKey string, objectKey string) error
- func (k *KeyCache) Generate(key string) error
- func (k *KeyCache) Get(objectStoreKey string, objectKey string) (Object, error)
- func (k *KeyCache) Len() int
- func (k *KeyCache) Purge() int
- func (k *KeyCache) PurgeOldest() error
- func (k *KeyCache) PurgeTimer(interval time.Duration, debug bool)
- func (k *KeyCache) Read(key string) (ObjectStore, error)
- func (k *KeyCache) SetExpire(key string, expire time.Duration, enableLocalExpire bool) error
- type NoCacheEntryError
- type NoObjectError
- type Object
- type ObjectStore
- func (o *ObjectStore) Add(item Item) bool
- func (o *ObjectStore) Delete(key string) error
- func (o *ObjectStore) Get(key string) (Object, error)
- func (o *ObjectStore) Len() int
- func (o *ObjectStore) Purge(expireDuration time.Duration) int
- func (o *ObjectStore) PurgeOldest() error
- func (o *ObjectStore) SetExpire(expire time.Duration, enableLocalExpire bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExceedsLengthError ¶
ExceedsLengthError satisfies the error interface
func (*ExceedsLengthError) Error ¶
func (e *ExceedsLengthError) Error() string
type InsufficientLengthError ¶
InsufficientLengthError satisfies the error interface
func (*InsufficientLengthError) Error ¶
func (e *InsufficientLengthError) Error() string
type Item ¶
Item is an interface for the object stored in memory
type KeyCache ¶
type KeyCache struct { OStore []ObjectStore Expire time.Duration // object expire duration LimitObjectLen bool // should number of objects be limited MaxObjectLen int // len of o.Object DateCreated time.Time // contains filtered or unexported fields }
KeyCache is a Fast Dataset Cache
func (*KeyCache) Add ¶
Add an object to the cache
func (*KeyCache) Delete ¶
Delete an object from cache
func (*KeyCache) Generate ¶
Generate generates an object store an initializes it
func (*KeyCache) Get ¶
Get an object from the cache
func (*KeyCache) PurgeOldest ¶
PurgeOldest purges oldest objects
func (*KeyCache) PurgeTimer ¶
PurgeTimer purges the KeyCache every x time.Duration's
func (*KeyCache) Read ¶
func (k *KeyCache) Read(key string) (ObjectStore, error)
Read searches the object store for keys and returns a struct
type NoCacheEntryError ¶
NoCacheEntryError satisfies the error interface
func (*NoCacheEntryError) Error ¶
func (e *NoCacheEntryError) Error() string
type NoObjectError ¶
NoObjectError satisfies the error interface
func (*NoObjectError) Error ¶
func (e *NoObjectError) Error() string
type Object ¶
type Object struct { Item Item // Item interface Valid bool // was the Object initialized (true) or is it default value (false) DateCreated time.Time // when was the Object created }
Object is an Item helper type
type ObjectStore ¶
type ObjectStore struct { Key string Object []Object LocalExpire bool // use local expire duration (ObjectStore.Expire) Expire time.Duration // local expire duration DateCreated time.Time DateModified time.Time // contains filtered or unexported fields }
ObjectStore contains objects and their metadata
func (*ObjectStore) Add ¶
func (o *ObjectStore) Add(item Item) bool
Add a new Object to ObjectStore (returns true if an existing object has been replaced)
func (*ObjectStore) Delete ¶
func (o *ObjectStore) Delete(key string) error
Delete objects from the ObjectStore
func (*ObjectStore) Get ¶
func (o *ObjectStore) Get(key string) (Object, error)
Get objects from the ObjectStore
func (*ObjectStore) Purge ¶
func (o *ObjectStore) Purge(expireDuration time.Duration) int
Purge deletes all expired Object's in ObjectStore, ignores expireDuration if o.LocalExpire is true
func (*ObjectStore) PurgeOldest ¶
func (o *ObjectStore) PurgeOldest() error
PurgeOldest deletes old elements to make space for new ones
func (*ObjectStore) SetExpire ¶
func (o *ObjectStore) SetExpire(expire time.Duration, enableLocalExpire bool)
SetExpire sets the local object expiration time.Duration