memory.go — fiber Source File
Architecture documentation for memory.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f453bafc_46b1_3619_f926_e077889a65a9["memory.go"] cc7104af_aece_1fe5_3985_791c7f34910c["context"] f453bafc_46b1_3619_f926_e077889a65a9 --> cc7104af_aece_1fe5_3985_791c7f34910c style f453bafc_46b1_3619_f926_e077889a65a9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// 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
package memory
import (
"context"
"fmt"
"sync"
"time"
"github.com/gofiber/utils/v2"
)
// Storage provides an in-memory implementation of the storage interface for
// testing purposes.
type Storage struct {
db map[string]Entry
done chan struct{}
gcInterval time.Duration
mux sync.RWMutex
}
// Entry represents a value stored in memory along with its expiration.
type Entry struct {
data []byte
// max value is 4294967295 -> Sun Feb 07 2106 06:28:15 GMT+0000
expiry uint32
}
// New creates a new memory storage.
func New(config ...Config) *Storage {
// Set default config
cfg := configDefault(config...)
// Create storage
store := &Storage{
db: make(map[string]Entry),
gcInterval: cfg.GCInterval,
done: make(chan struct{}),
}
// Start garbage collector
utils.StartTimeStampUpdater()
go store.gc()
return store
}
// Get returns the stored value for key, ignoring missing or expired entries by
// returning nil.
func (s *Storage) Get(key string) ([]byte, error) {
if key == "" {
return nil, nil
}
s.mux.RLock()
v, ok := s.db[key]
s.mux.RUnlock()
if !ok || v.expiry != 0 && v.expiry <= utils.Timestamp() {
return nil, nil
// ... (174 more lines)
Domain
Subdomains
Functions
Dependencies
- context
Source
Frequently Asked Questions
What does memory.go do?
memory.go is a source file in the fiber codebase, written in go. It belongs to the InternalStorage domain, MemoryStore subdomain.
What functions are defined in memory.go?
memory.go defines 2 function(s): New, wrapContextError.
What does memory.go depend on?
memory.go imports 1 module(s): context.
Where is memory.go in the architecture?
memory.go is located at internal/storage/memory/memory.go (domain: InternalStorage, subdomain: MemoryStore, directory: internal/storage/memory).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free