Skip to content

xopxe/lua-persistor

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

lua-persistor

Transparent persistence for Lua data! Seriously!

  • Depends on luafilesystem
  • Keys can only be strings valid as filenames
  • Can store/retrieve tables (no loops!), strings, numbers and booleans.
  • Contains a recursive directory purger, handle with care.

How?

-- load library
local persistor = require 'persistor'

-- get a persistor table.
-- if the root folder exists, data will be read from there.
-- if the name is omitted "$PWD/tmp-persistor" will be used.
-- if there was data from previous executions, it will still be there.
-- data inside this folder is used at will, do not use it for anything else
local p = persistor.new('path/to/root/folder')

-- also you can purge all stored data loading the persistor table as follows:
-- local p =  persistor.new('path/to/root/folder', true)

-- store something
p.pi = 3.14
p.circle = {center={x=0, y=0}, radius=0.5}

-- read something (possibly much later, in another run)
print (2 * p.pi * p.circle.radius)

Who?

xxopxe@gmail.com

About

Transparent persistence for Lua data! Seriously!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages