lua: simple tag cache enabling factoring way_function into smaller functions

This commit is contained in:
Emil Tin
2016-11-07 11:03:15 +01:00
committed by Patrick Niklaus
parent 6c682b2258
commit cff69178e8
2 changed files with 91 additions and 44 deletions
+35
View File
@@ -0,0 +1,35 @@
TagCache = {}
function TagCache.get(data, key)
local v = data.cache[key]
if v then
if v == '' then
return nil
else
return v
end
else
v = data.way:get_value_by_key(key)
if v == nil then
data.cache[key] = ''
return nil
else
data.cache[key] = v
if v == '' then
return nil
else
return v
end
end
end
end
function TagCache.set(data,key,value)
if value then
data.cache[key] = value
else
data.cache[key] = ''
end
end
return TagCache