Documentation
¶
Overview ¶
Package memory Is a copy of the storage memory from the external storage packet as a purpose to test the behavior in the unittests when using a storages from these packets
Index ¶
- Variables
- type Config
- type Entry
- type Storage
- func (s *Storage) Close() error
- func (s *Storage) Conn() map[string]Entry
- func (s *Storage) Delete(key string) error
- func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
- func (s *Storage) Get(key string) ([]byte, error)
- func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)
- func (s *Storage) Keys() ([][]byte, error)
- func (s *Storage) Reset() error
- func (s *Storage) ResetWithContext(ctx context.Context) error
- func (s *Storage) Set(key string, val []byte, exp time.Duration) error
- func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error
Constants ¶
This section is empty.
Variables ¶
var ConfigDefault = Config{ GCInterval: 10 * time.Second, }
ConfigDefault is the default config
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Time before deleting expired keys
//
// Default is 10 * time.Second
GCInterval time.Duration
}
Config defines the config for storage.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry represents a value stored in memory along with its expiration.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides an in-memory implementation of the storage interface for testing purposes. Storage is safe for concurrent use, except when callers keep using the live map returned by Conn. Access to that map requires external synchronization.
func (*Storage) Close ¶
Close stops the background garbage collector and releases resources associated with the storage instance. It blocks until the GC goroutine has exited and is safe to call multiple times from any number of goroutines.
func (*Storage) Conn ¶
Conn returns the underlying storage map. The returned map remains shared with the storage, so callers must not modify it and must synchronize any access that overlaps with other storage operations.
func (*Storage) DeleteWithContext ¶
DeleteWithContext removes the value for the given key while honoring context cancellation.
func (*Storage) Get ¶
Get returns the stored value for key, ignoring missing or expired entries by returning nil.
func (*Storage) GetWithContext ¶
GetWithContext retrieves the value for the given key while honoring context cancellation.
func (*Storage) ResetWithContext ¶
ResetWithContext clears all stored keys while honoring context cancellation.