Skip to content

implement cleanup of expired resources in Java? #83

Description

@dominik-cnx

We currently comment all return statements from del.lua using

values.put("delscript", readLuaScriptFromClasspath(LuaScript.DELETE).replaceAll("return", "--return"));

and then inline the modified script into cleanup.lua

for key,value in pairs(resourcesToClean) do
redis.log(redis.LOG_NOTICE, "cleanup resource: "..value)
KEYS[1] = string.sub(value, resourcePrefixLength+1, string.len(value))

--%(delscript) <-- del.lua with commented return statements

counter = counter + 1
end

There are several disadvantages with this approach:

a) We can't use functions such as

local function isResource(key)
return redis.call('exists',resourcesPrefix..key) <-- will be commented
end

in del.lua

b) We can't do a "return early from method"

c) We also increment the counter when nothing has been deleted

Hence the idea to get rid of the cleanup.lua and implement this in Java (but still call the del.lua).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions