CacheService
Simple module for caching any data.
Functions
CreateCache
CacheService:CreateCache(cacheName: string,--
The name of the cache
entryLimit: number?,--
Maximum number of entries (default 1000)
entryAgeLimit: number?--
Entry lifetime in seconds (default 3600)
) → CacheTypes
interface Cache {EntryLimit: number--
Maximum number of entries the cache will hold
EntryAgeLimit: number--
Number of seconds entries are allowed to exist
Entries: {[string]: {Data: any,EntryTime: number}}--
The cached entries
}Returns the named Cache, creating it if it does not already exist.
Set
CacheService:Set(cacheName: string,--
The name of the cache
index: string,--
The cache key
data: any--
The value to cache
) → ()Stores a value at the given index in the named cache.
Get
CacheService:Get(cacheName: string,--
The name of the cache
index: string--
The cache key to look up
) → any?Returns the cached value at the given index, or nil if missing or expired.
GetOrAdd
CacheService:GetOrAdd(cacheName: string,--
The name of the cache
index: string,--
The cache key to look up
addCallback: function--
Called to produce the value if not cached
) → any?
Returns the cached value at the given index. If missing or expired, calls
addCallback to produce a value, caches it, and returns it.