Skip to content

Files

Latest commit

960b9d2 · Sep 20, 2022

History

History
This branch is 10 commits ahead of, 73 commits behind vadv/gopher-lua-libs:master.

storage

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 20, 2022
Mar 24, 2019
Sep 20, 2022
Dec 28, 2018

storage GoDoc

Usage

local storage = require("storage")

-- storage.open
local s, err = storage.open("./test/db.json")
if err then error(err) end

-- storage:set(): key, value, ttl (default = 60s)
local err = s:set("key", {"one", "two", 1}, 10)
if err then error(err) end

-- storage:get()
local value, found, err = s:get("key")
if err then error(err) end
if not found then error("must be found") end
-- value == {"one", "two", 1}

-- storage:set(): override with set max ttl
local err = s:set("key", "override", nil)
local value, found, err = s:get("key")
if not(value == "override") then error("must be found") end

-- storage:keys()
local list = s:keys()
-- list == {"key"}

-- storage:dump()
local dump, err = s:dump()
if err then error(err) end
-- list == {"key" = "override"}