Documentation
¶
Index ¶
Constants ¶
const ImportPath = "k6/x/working-memory"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache struct encapsulates an in-memory cache with a mutex for concurrent access management.
func (*Cache) Get ¶
Get retrieves a value from the cache by its id. Parameters: - id: Unique identifier of the cache entry. Returns: - The cached value if found, or nil if the entry does not exist. - An error if the cache is not initialized or another issue occurs.
func (*Cache) Init ¶
Init initializes the Cache with a default expiration time and cleanup interval. Parameters: - defaultExpiration: Cache expiration time in seconds. - cleanupInterval: Interval in seconds at which expired items are removed from the cache.
func (*Cache) Set ¶
Set stores a value in the cache under the specified id with an optional expiration. Parameters: - id: Unique identifier for the cache entry. - value: Value to store in the cache. - expiration: Optional expiration time in seconds. Defaults to the cache's default expiration if omitted. Returns: - A boolean indicating if the value was successfully set. - An error if the cache is not initialized or another issue occurs.