Marco-Zheng opened a new issue #5365:
URL: https://github.com/apache/apisix/issues/5365
### Issue description
When i set cache in _M.init() by using timer , it was successfuly, but get
nil in _M.access() function, see details as below Steps
### Environment
- apisix version (cmd: `apisix version`): 2.6
### Steps to reproduce
Here is my extension code to timely fetch some data from etcd in
traffic-split plugin
```
OIDC_CACHE_TTL
local version_control_lrucache = lru_new(1024 * 4)
local function traffic_info_fetch_per_env(profile_active)
local key = "/version_control/"..profile_active
local res, err = core.etcd.get(key)
if not res or res.status ~= 200 then
--core.log.error("failed to get global rule[", key, "]: ", err)
return
end
local version_control = res.body.node.value
version_control_lrucache:set("version_control:"..profile_active,
version_control, OIDC_CACHE_TTL)
core.log.error("push complte")
end
local function traffic_info_fetch()
core.log.error("start traffic info pull")
local profile_actives = {"dev", "uat", "pre", "prod"}
for _, profile_active in ipairs(profile_actives) do
traffic_info_fetch_per_env(profile_active)
end
end
function _M.init()
timers.register_timer("plugin#traffic-split", traffic_info_fetch, true)
end
function _M.destroy()
timers.unregister_timer("plugin#traffic-split", true)
end
```
Then i add below code in _M.acccess() function in order to get the data from
cache
```
local version_control = version_control_lrucache:get("version_control:uat")
```
But the weird thing is that my cache settings are successful , when I fetch
data from cache, it was nil
My `lua_code_cache` is `open`

### Actual result
cache get is nil
### Error log
No error log
### Expected result
get the cache what i set in
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]