]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lua/sandbox: default cache backend/size
authorMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 10 Jun 2015 21:47:16 +0000 (23:47 +0200)
committerMarek Vavruša <marek.vavrusa@nic.cz>
Wed, 10 Jun 2015 21:47:16 +0000 (23:47 +0200)
daemon/lua/sandbox.lua

index 1e763bfcc844a8bd0f2266e5b11f8991f2a45763..a94b050cbf0783d4814550bffc4664c1235d252d 100644 (file)
@@ -52,8 +52,14 @@ setmetatable(modules, {
 -- `cache.{size|storage} = value`
 setmetatable(cache, {
        __newindex = function (t,k,v)
-               if     k == 'size'    then t.open(v, rawget(t, 'current_storage'))
-               elseif k == 'storage' then t.open(rawget(t, 'current_size'), v)
+               -- Defaults
+               local storage = rawget(t, 'current_storage')
+               if not storage then storage = 'lmdb://' end
+               local size = rawget(t, 'current_size')
+               if not size then size = 10*MB end
+               -- Declarative interface for cache
+               if     k == 'size'    then t.open(v, storage)
+               elseif k == 'storage' then t.open(size, v)
                else   rawset(t, k, v) end
        end
 })