Mercurial > hg > nginx-site
comparison xml/en/docs/http/ngx_http_js_module.xml @ 2990:7e83ebfac8ca
Documented the js_shared_dict_zone directive.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Thu, 06 Jul 2023 12:31:31 +0100 |
parents | 9719a0184a67 |
children | 98bd95a5ac70 |
comparison
equal
deleted
inserted
replaced
2989:703d3450cd81 | 2990:7e83ebfac8ca |
---|---|
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> | 7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
8 | 8 |
9 <module name="Module ngx_http_js_module" | 9 <module name="Module ngx_http_js_module" |
10 link="/en/docs/http/ngx_http_js_module.html" | 10 link="/en/docs/http/ngx_http_js_module.html" |
11 lang="en" | 11 lang="en" |
12 rev="37"> | 12 rev="38"> |
13 | 13 |
14 <section id="summary"> | 14 <section id="summary"> |
15 | 15 |
16 <para> | 16 <para> |
17 The <literal>ngx_http_js_module</literal> module is used to implement | 17 The <literal>ngx_http_js_module</literal> module is used to implement |
621 </para> | 621 </para> |
622 | 622 |
623 </directive> | 623 </directive> |
624 | 624 |
625 | 625 |
626 <directive name="js_shared_dict_zone"> | |
627 <syntax> | |
628 <literal>zone</literal>=<value>name</value>:<value>size</value> | |
629 [<literal>timeout</literal>=<value>time</value>] | |
630 [<literal>type</literal>=<literal>string</literal>|<literal>number</literal>] | |
631 [<literal>evict</literal>]</syntax> | |
632 <default/> | |
633 <context>http</context> | |
634 <appeared-in>0.8.0</appeared-in> | |
635 | |
636 <para> | |
637 Sets the <value>name</value> and <value>size</value> of the shared memory zone | |
638 that keeps the key-value dictionary | |
639 shared between worker processes. | |
640 </para> | |
641 | |
642 <para> | |
643 By default the shared dictionary uses a string as a key and a value. | |
644 The optional <literal>type</literal> parameter | |
645 allows redefining the value type to number. | |
646 </para> | |
647 | |
648 <para> | |
649 The optional <literal>timeout</literal> parameter sets | |
650 the time after which all shared dictionary entries are removed from the zone. | |
651 </para> | |
652 | |
653 <para> | |
654 The optional <literal>evict</literal> parameter removes the oldest | |
655 key-value pair when the zone storage is exhausted. | |
656 </para> | |
657 | |
658 <para> | |
659 Examples: | |
660 <example> | |
661 example.conf: | |
662 # Creates a 1Mb dictionary with string values, | |
663 # removes key-value pairs after 60 seconds of inactivity: | |
664 js_shared_dict_zone zone=foo:1M timeout=60s; | |
665 | |
666 # Creates a 512Kb dictionary with string values, | |
667 # forcibly removes oldest key-value pairs when the zone is exhausted: | |
668 js_shared_dict_zone zone=bar:512K timeout=30s evict; | |
669 | |
670 # Creates a 32Kb permanent dictionary with number values: | |
671 js_shared_dict_zone zone=num:32k type=number; | |
672 | |
673 example.js: | |
674 function get(r) { | |
675 r.return(200, ngx.shared.foo.get(r.args.key)); | |
676 } | |
677 | |
678 function set(r) { | |
679 r.return(200, ngx.shared.foo.set(r.args.key, r.args.value)); | |
680 } | |
681 | |
682 function delete(r) { | |
683 r.return(200, ngx.shared.bar.delete(r.args.key)); | |
684 } | |
685 | |
686 function increment(r) { | |
687 r.return(200, ngx.shared.num.incr(r.args.key, 2)); | |
688 } | |
689 </example> | |
690 </para> | |
691 | |
692 </directive> | |
693 | |
694 | |
626 <directive name="js_var"> | 695 <directive name="js_var"> |
627 <syntax><value>$variable</value> [<value>value</value>]</syntax> | 696 <syntax><value>$variable</value> [<value>value</value>]</syntax> |
628 <default/> | 697 <default/> |
629 <context>http</context> | 698 <context>http</context> |
630 <context>server</context> | 699 <context>server</context> |