0Pricing
Lua Academy · Lesson

Shared Memory Dictionaries

Cache data across workers with ngx.shared.DICT for low-latency lookups.

What Is ngx.shared.DICT?

ngx.shared.DICT is a shared memory zone accessible by all Nginx worker processes. It provides O(1) get/set/incr operations for caching and coordination.

Declaring Shared Memory in nginx.conf

Allocate shared dictionaries with a name and size in the http block.

# nginx.conf
http {
  lua_shared_dict rate_limit 10m;
  lua_shared_dict cache      50m;
  lua_shared_dict locks      1m;
}

All lessons in this course

  1. OpenResty Architecture
  2. Handling HTTP Requests in Lua
  3. Cosockets and Non-Blocking TCP
  4. Shared Memory Dictionaries
← Back to Lua Academy