luakongkong-plugin

kong cache invalidation throws error : key must be a string


In a custom plugin I need to invalidate a Kong cache entry. When I use

kong.cache.invalidate_local("thisisastring")

I get error

key must be a string
 stack traceback:
    [C]: in function 'error'
    /usr/local/share/lua/5.1/kong/cache/init.lua:226: in function 'invalidate_local'

I'm using Kong 2.7.0.

https://github.com/Kong/kong/blob/2.7.0/kong/cache/init.lua#L226

What is wrong?


Solution

  • You should use : not .

          kong.cache:invalidate_local("your string")
    

    More info about difference between : and .