Cache emmy lua docs

main
4n0n 2 years ago
parent 1ce1d193e1
commit c668600cd4
  1. 9
      src/Cache/Cache.lua

@ -3,12 +3,17 @@ local Cache = {}
Cache.__index = Cache Cache.__index = Cache
-- Constructor -- Constructor
---@return Cache
function Cache:New() function Cache:New()
local self = setmetatable({}, Cache) local self = setmetatable({}, Cache)
self.cache = {} self.cache = {}
return self return self
end end
---@param key any
---@param value any
---@param duration number
---@return nil
function Cache:Set(key, value, duration) function Cache:Set(key, value, duration)
self.cache = self.cache or {} self.cache = self.cache or {}
self.cache[key] = { self.cache[key] = {
@ -18,6 +23,8 @@ function Cache:Set(key, value, duration)
} }
end end
---@param key any
---@return any
function Cache:Get(key) function Cache:Get(key)
self.cache = self.cache or {} self.cache = self.cache or {}
local cache = self.cache[key] local cache = self.cache[key]
@ -31,6 +38,8 @@ function Cache:Get(key)
return nil return nil
end end
---@param key any
---@return boolean
function Cache:IsCached(key) function Cache:IsCached(key)
self.cache = self.cache or {} self.cache = self.cache or {}
local cache = self.cache[key] local cache = self.cache[key]

Loading…
Cancel
Save