Skip to content

Commit

Permalink
deps(*) bump lua-resty-mlcache to 2.6.0 (#9287)
Browse files Browse the repository at this point in the history
* bump lua-resty-mlcache to 2.6.0
* update changelog
* cache marshall with string.buffer
* style fix
  • Loading branch information
chronolaw authored Aug 23, 2022
1 parent 3763f6b commit 9c990a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@
[#8845](https://github.com/Kong/kong/pull/8845)
- Bumped penlight from 1.12.0 to 1.13.1
[#9206](https://github.com/Kong/kong/pull/9206)
- Bumped lua-resty-mlcache from 2.5.0 to 2.6.0
[#9287](https://github.com/Kong/kong/pull/9287)

### Additions

Expand Down
2 changes: 1 addition & 1 deletion kong-3.0.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = {
"lua-protobuf == 0.3.3",
"lua-resty-worker-events == 1.0.0",
"lua-resty-healthcheck == 1.6.1",
"lua-resty-mlcache == 2.5.0",
"lua-resty-mlcache == 2.6.0",
"lua-messagepack == 0.5.2",
"lua-resty-openssl == 0.8.10",
"lua-resty-counter == 0.2.1",
Expand Down
20 changes: 14 additions & 6 deletions kong/cache/marshall.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
-------------------------------------------------------------------------------
-- NOTE: the following is copied from lua-resty-mlcache: --
------------------------------------------------------------------------ cut --
local cjson = require "cjson.safe"
local codec
do
local pok
pok, codec = pcall(require, "string.buffer")
if not pok then
codec = require "cjson"
end
end


local type = type
local pcall = pcall
local error = error
local tostring = tostring
local fmt = string.format
local now = ngx.now
local cjson_encode = cjson.encode
local encode = codec.encode


local TYPES_LOOKUP = {
Expand Down Expand Up @@ -42,12 +50,12 @@ local marshallers = {
end,

[4] = function(t) -- table
local json, err = cjson_encode(t)
if not json then
return nil, "could not encode table value: " .. err
local pok, str = pcall(encode, t)
if not pok then
return nil, "could not encode table value: " .. str
end

return json
return str
end,
}

Expand Down

0 comments on commit 9c990a7

Please sign in to comment.