Internal

internal/storage/memory

import "github.com/gofiber/fiber/v3/internal/storage/memory"

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

Variables

ConfigDefault is the default config

Source: internal/storage/memory/config.go:16

var ConfigDefault = Config{
	GCInterval: 10 * time.Second,
}

Functions

func New(config ...Config) *Storage

Source: internal/storage/memory/memory.go:36

New creates a new memory storage.

Types

type Config

Source: internal/storage/memory/config.go:8

Config defines the config for storage.

type Config struct {
	// Time before deleting expired keys
	//
	// Default is 10 * time.Second
	GCInterval time.Duration
}
Fields
  • GCInterval time.Duration

    Time before deleting expired keys

    Default is 10 * time.Second

type Entry

Source: internal/storage/memory/memory.go:29

Entry represents a value stored in memory along with its expiration.

type Entry struct {
	// contains filtered or unexported fields
}

type Storage

Source: internal/storage/memory/memory.go:19

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.

type Storage struct {
	// contains filtered or unexported fields
}

func (s *Storage) Close() error

Source: internal/storage/memory/memory.go:157

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 (s *Storage) Conn() map[string]Entry

Source: internal/storage/memory/memory.go:210

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 (s *Storage) Delete(key string) error

Source: internal/storage/memory/memory.go:116

Delete removes the value stored for key.

func (s *Storage) DeleteWithContext(ctx context.Context, key string) error

Source: internal/storage/memory/memory.go:129

DeleteWithContext removes the value for the given key while honoring context cancellation.

func (s *Storage) Get(key string) ([]byte, error)

Source: internal/storage/memory/memory.go:57

Get returns the stored value for key, ignoring missing or expired entries by returning nil.

func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)

Source: internal/storage/memory/memory.go:75

GetWithContext retrieves the value for the given key while honoring context cancellation.

func (s *Storage) Keys() ([][]byte, error)

Source: internal/storage/memory/memory.go:217

Keys returns all keys stored in the memory storage.

func (s *Storage) Reset() error

Source: internal/storage/memory/memory.go:137

Reset clears all keys and values from the storage map.

func (s *Storage) ResetWithContext(ctx context.Context) error

Source: internal/storage/memory/memory.go:147

ResetWithContext clears all stored keys while honoring context cancellation.

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

Source: internal/storage/memory/memory.go:84

Set saves val under key, expiring after exp rounded up to whole seconds; a non-positive exp keeps the entry indefinitely.

func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error

Source: internal/storage/memory/memory.go:108

SetWithContext sets the value for the given key while honoring context cancellation.