Documentation
¶
Index ¶
- type Store
- func (s *Store) Clear(ctx context.Context, namespace []string) error
- func (s *Store) Delete(ctx context.Context, namespace []string, key string) error
- func (s *Store) Get(ctx context.Context, namespace []string, key string) (*store.Value, error)
- func (s *Store) List(ctx context.Context, namespace []string) ([]string, error)
- func (s *Store) Namespaces() []string
- func (s *Store) Put(ctx context.Context, namespace []string, key string, value interface{}) error
- func (s *Store) Search(ctx context.Context, namespace []string, filter map[string]interface{}) ([]*store.Value, error)
- func (s *Store) Size() int
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 a thread-safe in-memory implementation of store.Store.
Suitable for:
- Development and testing
- Small-scale deployments
- Ephemeral data that doesn't need persistence
Performance optimizations:
- Uses sync.RWMutex for efficient read-heavy workloads
- Object pooling with sync.Pool to reduce GC pressure
- Optimized lock granularity to minimize write lock duration
- Inverted index for O(1) metadata-based search queries
func (*Store) Delete ¶
Delete removes a value by namespace and key. Returns the old value to the object pool.
func (*Store) Namespaces ¶
Namespaces returns all namespace keys currently in the store.
func (*Store) Put ¶
Put stores a value with the given namespace and key. Optimizations:
- Uses object pool to reduce allocations
- Minimizes write lock duration by preparing data outside critical section
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, namespace []string, filter map[string]interface{}) ([]*store.Value, error)
Search finds values matching the filter within a namespace. Optimization: Uses inverted index for O(1) lookup when filter is provided, falling back to linear scan only when no filter is specified.
Click to show internal directories.
Click to hide internal directories.