# Ngx.shared\_dict.get\_keys usage

**URL:** <https://www.ruby-forum.com/t/ngx-shared-dict-get-keys-usage/231397>\
**Category:** NGINX\
**Created:** [August 6, 2014, 8:45am UTC](https://www.ruby-forum.com/t/ngx-shared-dict-get-keys-usage/231397 "2014-08-06T08:45:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 6, 2014, 8:45am UTC](https://www.ruby-forum.com/t/ngx-shared-dict-get-keys-usage/231397/1 "2014-08-06T08:45:02Z")

</div>

Hi,

I’m trying to use the lua module in combination with ngx.shared.DICT  
feature to record some statistics for nginx (and upstreams’) health  
monitoring.

When I do dict.get\_keys(100), I see the following error in nginx  
error.log:

2014/08/06 06:27:55 [error] 13446#0: \*1 lua entry thread aborted:  
runtime  
error: /opt/inmobi/nginx/customlua/logging.lua:56: bad argument #1 to  
‘get\_keys’ (userdata expected, got number)  
stack traceback:  
coroutine 0:  
[C]: in function ‘get\_keys’  
/opt/inmobi/nginx/customlua/logging.lua:56: in function  
‘get\_all\_plots’  
[string “content\_by\_lua”]:3: in function \<[string  
“content\_by\_lua”]:1\>, client: 127.0.0.1, server: , request: “GET /stat2  
HTTP/1.1”, host: “localhost”

I’m using ngx\_openresty version: ngx\_openresty/1.2.4.11

Could someone please guide me how to use the get\_keys method of the  
shared  
dict in nginx/lua?

Cheers,

-Suraj

[1] Much in the spirit of  
[http://blog.cloudflare.com/pushing-nginx-to-its-limit-with-lua](http://blog.cloudflare.com/pushing-nginx-to-its-limit-with-lua)

–  
An Onion is the Onion skin and the Onion under the skin until the Onion  
Skin without any Onion underneath.

–

* * *

The information contained in this communication is intended solely for  
the  
use of the individual or entity to whom it is addressed and others  
authorized to receive it. It may contain confidential or legally  
privileged  
information. If you are not the intended recipient you are hereby  
notified  
that any disclosure, copying, distribution or taking any action in  
reliance  
on the contents of this information is strictly prohibited and may be  
unlawful. If you have received this communication in error, please  
notify  
us immediately by responding to this email and then delete it from your  
system. The firm is neither liable for the proper and complete  
transmission  
of the information contained in this communication nor for any delay in  
its  
receipt.

---

<div class="post-metadata">

**Author:** ![snk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@snk](https://www.ruby-forum.com/u/snk)\
**Post date:** [August 6, 2014, 8:57am UTC](https://www.ruby-forum.com/t/ngx-shared-dict-get-keys-usage/231397/2 "2014-08-06T08:57:32Z")

</div>

On Wed, Aug 6, 2014 at 12:14 PM, Suraj K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> When I do dict.get\_keys(100), I see the following error in nginx error.log:

Never mind. I figured one must do dict:get\_keys() and not  
dict.get\_keys()

That makes my first question and my first answer on this list on the  
same  
thread! 😉

Thanks,

-Suraj

–

* * *

The information contained in this communication is intended solely for  
the  
use of the individual or entity to whom it is addressed and others  
authorized to receive it. It may contain confidential or legally  
privileged  
information. If you are not the intended recipient you are hereby  
notified  
that any disclosure, copying, distribution or taking any action in  
reliance  
on the contents of this information is strictly prohibited and may be  
unlawful. If you have received this communication in error, please  
notify  
us immediately by responding to this email and then delete it from your  
system. The firm is neither liable for the proper and complete  
transmission  
of the information contained in this communication nor for any delay in  
its  
receipt.

---

<div class="post-metadata">

**Author:** ![snk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@snk](https://www.ruby-forum.com/u/snk)\
**Post date:** [August 6, 2014, 8:59am UTC](https://www.ruby-forum.com/t/ngx-shared-dict-get-keys-usage/231397/3 "2014-08-06T08:59:56Z")

</div>

hmmm… also you’d better to upgrade the openresty version. it’ too old.  
🙂

–  
smallfish [http://chenxiaoyu.org](http://chenxiaoyu.org)
