ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit 877aeb23af72a7c136707e526131bbaf08ce5a5a
parent 72683986685cdb172c57b99b8971f4e7e4894704
Author: Hugo Soucy <hugo.soucy@equisoft.com>
Date:   Sun, 29 Sep 2019 19:25:42 -0400

Start a cache module

Diffstat:
Aferron/cache.lua | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/ferron/cache.lua b/ferron/cache.lua @@ -0,0 +1,26 @@ +-- cache.lua +local cache = {} +local cachemeta = { + __call = function(self, key, vars) + print(key) + end +} + +local json = require 'dkjson' +local fl = require 'ferron.utilities.file-utils' +local tb = require 'ferron.utilities.table-utils' + +function cache.init(sitedata) + local cachetable + local cachefile = sitedata.data .. '/cache.json' + + if not fl.isFile(cachefile) then + fl.pushfilecontent(cachefile, '{}') + end + + cachetable = json.decode(fl.pullfilecontent(cachefile)) + + return cachetable +end + +return setmetatable(cache, cachemeta)