Set sets (or overwrite if already exists) a new value for key.
Parameters
key: K
value: T
Returns void
setFunc
setFunc(key, fn): void
SetFunc sets (or overwrite if already exists) a new value resolved
from the function callback for the provided key.
The function callback receives as argument the old store element value (if exists).
If there is no old store element, the argument will be the T zero value.
Example:
s := store.New[string, int](nil) s.SetFunc("count", func(old int) int { return old + 1 })
SetIfLessThanLimit sets (or overwrite if already exist) a new value for key.
This method is similar to Set() but it will skip adding new elements
to the store if the store length has reached the specified limit.
false is returned if maxAllowedElements limit is reached.
Parameters
key: K
value: T
maxAllowedElements: number
Returns boolean
unmarshalJSON
unmarshalJSON(data): void
UnmarshalJSON implements [json.Unmarshaler] and imports the
provided JSON data into the store.
The store entries that match with the ones from the data will be overwritten with the new value.
Parameters
data: string | number[]
Returns void
values
values(): T[]
Values returns a slice with all of the store values.
Store defines a concurrent safe in memory key-value data store.