Documentation ¶
Overview ¶
Package cache provides simple in-memory key:value store
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is cache store
func New ¶
New creates new store instance
Example ¶
store := New(time.Second, time.Minute) store.Set("test", "ABCD") fmt.Println(store.Get("test"))
Output: ABCD
func (*Store) Delete ¶
Delete removes item from cache
Example ¶
store := New(time.Second, time.Minute) store.Set("test", "ABCD") store.Delete("test") fmt.Println(store.Get("test"))
Output: <nil>
func (*Store) Flush ¶
func (s *Store) Flush()
Flush removes all data from cache
Example ¶
store := New(time.Second, time.Minute) store.Set("test", "ABCD") store.Flush() fmt.Println(store.Get("test"))
Output: <nil>
func (*Store) Get ¶
Get returns item from cache or nil
Example ¶
store := New(time.Second, time.Minute) store.Set("test", "ABCD") fmt.Println(store.Get("test"))
Output: ABCD
func (*Store) GetWithExpiration ¶
GetWithExpiration returns item from cache and expiration date or nil
Example ¶
store := New(time.Second, time.Minute) store.Set("test", "ABCD") item, exp := store.GetWithExpiration("test") fmt.Println(item, exp.String())
Output:
Click to show internal directories.
Click to hide internal directories.