Hi,
> On Sep 1, 2016, at 20:01, Peng Liu <liup...@gmail.com> wrote:
>
> Hi,
>
> How to sort the ngx.shared.DICT by key or value in a easy way?
There's no interface to do this; the underlying data structure that shared dicts use is designed for fast lookups and inserts, not sorting the storage.
if your shared dict has many values this will be a very slow and expensive operation. You could grab all of the keys and values using get_keys() and sorting the resulting values, and then calling get() for all keys (if you need the values), but this will be very slow (and will block all read and write access by other processes of threads while get_keys() traverses the storage zone).
You may want to take a look at your use case. Ask yourself why you need to sort the keys or values of the entire dictionary. You may find that using this type of k/v store is not appropriate for your use.