Skip to content

Commit

Permalink
chore(deps) replace vendor mlcache with 2.0.1 upstream
Browse files Browse the repository at this point in the history
This is part of a series of fixes:
- thibaultcha/lua-resty-mlcache#41
- thibaultcha/lua-resty-mlcache#42
- #3311
- #3341

Changes:

* remove vendor mlcache.lua file which had received patches for Kong
  support
* add lua-resty-mlcache 2.0.1 as a dependency
* implement custom IPC options for the DB mlcache instance

Changelog of mlcache 2.0.0:

  https://github.com/thibaultcha/lua-resty-mlcache/blob/master/CHANGELOG.md#200

Changelog of mlcache 2.0.1:

  https://github.com/thibaultcha/lua-resty-mlcache/blob/master/CHANGELOG.md#201
  • Loading branch information
thibaultcha committed Apr 24, 2018
1 parent b0ee864 commit 6f9096a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 488 deletions.
3 changes: 1 addition & 2 deletions kong-0.13.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies = {
"lua-resty-worker-events == 0.3.2",
"lua-resty-mediador == 0.1.2",
"lua-resty-healthcheck == 0.4.0",
"lua-resty-mlcache == 2.0.1",
}
build = {
type = "builtin",
Expand All @@ -47,8 +48,6 @@ build = {

["kong.cache"] = "kong/cache.lua",

["kong.mlcache"] = "kong/mlcache.lua",

["kong.templates.nginx"] = "kong/templates/nginx.lua",
["kong.templates.nginx_kong"] = "kong/templates/nginx_kong.lua",
["kong.templates.kong_defaults"] = "kong/templates/kong_defaults.lua",
Expand Down
18 changes: 15 additions & 3 deletions kong/cache.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local kong_mlcache = require "kong.mlcache"
local resty_mlcache = require "resty.mlcache"


local type = type
Expand Down Expand Up @@ -69,11 +69,23 @@ function _M.new(opts)
return error("opts.resty_lock_opts must be a table")
end

local mlcache, err = kong_mlcache.new(SHM_CACHE, opts.worker_events, {
local mlcache, err = resty_mlcache.new("kong_db_cache", SHM_CACHE, {
lru_size = LRU_SIZE,
ttl = max(opts.ttl or 3600, 0),
neg_ttl = max(opts.neg_ttl or 300, 0),
resty_lock_opts = opts.resty_lock_opts,
ipc = {
register_listeners = function(events)
for _, event_t in pairs(events) do
opts.worker_events.register(function(data)
event_t.handler(data)
end, "mlcache", event_t.channel)
end
end,
broadcast = function(channel, data)
opts.worker_events.post("mlcache", channel, data)
end
}
})
if not mlcache then
return nil, "failed to instantiate mlcache: " .. err
Expand Down Expand Up @@ -121,7 +133,7 @@ function _M:probe(key)
return error("key must be a string")
end

local ttl, err, v = self.mlcache:probe(key)
local ttl, err, v = self.mlcache:peek(key)
if err then
return nil, "failed to probe from node cache: " .. err
end
Expand Down
Loading

0 comments on commit 6f9096a

Please sign in to comment.