# HG changeset patch # User Yaroslav Zhuravlev # Date 1688643091 -3600 # Node ID 7e83ebfac8ca055ccd66341f340616a65a0adb4e # Parent 703d3450cd817e5e4726862430b6648ec7c989f6 Documented the js_shared_dict_zone directive. diff --git a/xml/en/docs/http/ngx_http_js_module.xml b/xml/en/docs/http/ngx_http_js_module.xml --- a/xml/en/docs/http/ngx_http_js_module.xml +++ b/xml/en/docs/http/ngx_http_js_module.xml @@ -9,7 +9,7 @@ + rev="38">
@@ -623,6 +623,75 @@ since + + + zone=name:size + [timeout=time] + [type=string|number] + [evict] + +http +0.8.0 + + +Sets the name and size of the shared memory zone +that keeps the key-value dictionary +shared between worker processes. + + + +By default the shared dictionary uses a string as a key and a value. +The optional type parameter +allows redefining the value type to number. + + + +The optional timeout parameter sets +the time after which all shared dictionary entries are removed from the zone. + + + +The optional evict parameter removes the oldest +key-value pair when the zone storage is exhausted. + + + +Examples: + +example.conf: + # Creates a 1Mb dictionary with string values, + # removes key-value pairs after 60 seconds of inactivity: + js_shared_dict_zone zone=foo:1M timeout=60s; + + # Creates a 512Kb dictionary with string values, + # forcibly removes oldest key-value pairs when the zone is exhausted: + js_shared_dict_zone zone=bar:512K timeout=30s evict; + + # Creates a 32Kb permanent dictionary with number values: + js_shared_dict_zone zone=num:32k type=number; + +example.js: + function get(r) { + r.return(200, ngx.shared.foo.get(r.args.key)); + } + + function set(r) { + r.return(200, ngx.shared.foo.set(r.args.key, r.args.value)); + } + + function delete(r) { + r.return(200, ngx.shared.bar.delete(r.args.key)); + } + + function increment(r) { + r.return(200, ngx.shared.num.incr(r.args.key, 2)); + } + + + + + + $variable [value] diff --git a/xml/en/docs/stream/ngx_stream_js_module.xml b/xml/en/docs/stream/ngx_stream_js_module.xml --- a/xml/en/docs/stream/ngx_stream_js_module.xml +++ b/xml/en/docs/stream/ngx_stream_js_module.xml @@ -9,7 +9,7 @@ + rev="36">
@@ -608,6 +608,75 @@ since + + + zone=name:size + [timeout=time] + [type=string|number] + [evict] + +stream +0.8.0 + + +Sets the name and size of the shared memory zone +that keeps the key-value dictionary +shared between worker processes. + + + +By default the shared dictionary uses a string as a key and a value. +The optional type parameter +allows redefining the value type to number. + + + +The optional timeout parameter sets +the time after which all shared dictionary entries are removed from the zone. + + + +The optional evict parameter removes the oldest +key-value pair when the zone storage is exhausted. + + + +Examples: + +example.conf: + # Creates a 1Mb dictionary with string values, + # removes key-value pairs after 60 seconds of inactivity: + js_shared_dict_zone zone=foo:1M timeout=60s; + + # Creates a 512Kb dictionary with string values, + # forcibly removes oldest key-value pairs when the zone is exhausted: + js_shared_dict_zone zone=bar:512K timeout=30s evict; + + # Creates a 32Kb permanent dictionary with number values: + js_shared_dict_zone zone=num:32k type=number; + +example.js: + function get(r) { + r.return(200, ngx.shared.foo.get(r.args.key)); + } + + function set(r) { + r.return(200, ngx.shared.foo.set(r.args.key, r.args.value)); + } + + function delete(r) { + r.return(200, ngx.shared.bar.delete(r.args.key)); + } + + function increment(r) { + r.return(200, ngx.shared.num.incr(r.args.key, 2)); + } + + + + + + $variable [value] diff --git a/xml/ru/docs/http/ngx_http_js_module.xml b/xml/ru/docs/http/ngx_http_js_module.xml --- a/xml/ru/docs/http/ngx_http_js_module.xml +++ b/xml/ru/docs/http/ngx_http_js_module.xml @@ -9,7 +9,7 @@ + rev="38">
@@ -624,6 +624,75 @@ js_preload_object map.json; + + + zone=имя:размер + [timeout=время] + [type=строка|число] + [evict] + +http +0.8.0 + + +Задаёт имя и размер зоны разделяемой памяти, +в которой хранится словарь ключей и значений, +разделяемый между рабочими процессами. + + + +По умолчанию в качестве ключа и значения используется строка. +Необязательный параметр type +позволяет изменить тип значения на число. + + + +Необязательный параметр timeout задаёт время, +по завершении которого все записи в словаре удаляются из зоны. + + + +Необязательный параметр evict удаляет самую старую +пару ключ-значение при переполнении зоны. + + + +Пример: + +example.conf: + # Создаётся словарь размером 1Мб со строковыми значениями, + # пары ключ-значение удаляются при отсутствии активности в течение 60 секунд: + js_shared_dict_zone zone=foo:1M timeout=60s; + + # Создаётся словарь размером 512Кб со строковыми значениями, + # удаляется самая старая пара ключ-значение при переполнении зоны: + js_shared_dict_zone zone=bar:512K timeout=30s evict; + + # Создаётся постоянный словарь размером 32Кб с числовыми значениями: + js_shared_dict_zone zone=num:32k type=number; + +example.js: + function get(r) { + r.return(200, ngx.shared.foo.get(r.args.key)); + } + + function set(r) { + r.return(200, ngx.shared.foo.set(r.args.key, r.args.value)); + } + + function delete(r) { + r.return(200, ngx.shared.bar.delete(r.args.key)); + } + + function increment(r) { + r.return(200, ngx.shared.num.incr(r.args.key, 2)); + } + + + + + + $переменная [значение] diff --git a/xml/ru/docs/stream/ngx_stream_js_module.xml b/xml/ru/docs/stream/ngx_stream_js_module.xml --- a/xml/ru/docs/stream/ngx_stream_js_module.xml +++ b/xml/ru/docs/stream/ngx_stream_js_module.xml @@ -9,7 +9,7 @@ + rev="36">
@@ -607,6 +607,75 @@ js_preload_object map.json; + + + zone=имя:размер + [timeout=время] + [type=строка|число] + [evict] + +stream +0.8.0 + + +Задаёт имя и размер зоны разделяемой памяти, +в которой хранится словарь ключей и значений, +разделяемый между рабочими процессами. + + + +По умолчанию в качестве ключа и значения используется строка. +Необязательный параметр type +позволяет изменить тип значения на число. + + + +Необязательный параметр timeout задаёт время, +по завершении которого все записи в словаре удаляются из зоны. + + + +Необязательный параметр evict удаляет самую старую +пару ключ-значение при переполнении зоны. + + + +Пример: + +example.conf: + # Создаётся словарь размером 1Мб со строковыми значениями, + # пары ключ-значение удаляются при отсутствии активности в течение 60 секунд: + js_shared_dict_zone zone=foo:1M timeout=60s; + + # Создаётся словарь размером 512Кб со строковыми значениями, + # удаляется самая старая пара ключ-значение при переполнении зоны: + js_shared_dict_zone zone=bar:512K timeout=30s evict; + + # Создаётся постоянный словарь размером 32Кб с числовыми значениями: + js_shared_dict_zone zone=num:32k type=number; + +example.js: + function get(r) { + r.return(200, ngx.shared.foo.get(r.args.key)); + } + + function set(r) { + r.return(200, ngx.shared.foo.set(r.args.key, r.args.value)); + } + + function delete(r) { + r.return(200, ngx.shared.bar.delete(r.args.key)); + } + + function increment(r) { + r.return(200, ngx.shared.num.incr(r.args.key, 2)); + } + + + + + + $переменная [значение]