doc: added performance notes to the sections for ngx.var and ngx.ctx.
This commit is contained in:
Родитель
7a20b07705
Коммит
06b7476b27
|
@ -2439,7 +2439,9 @@ local val = ngx.var.some_var
|
|||
--- use the val repeatedly later
|
||||
```
|
||||
|
||||
to prevent (temporary) memory leaking within the current request's lifetime.
|
||||
to prevent (temporary) memory leaking within the current request's lifetime. Another way of caching the result is to use the [ngx.ctx](#ngxctx) table.
|
||||
|
||||
This API requires a relatively expensive metamethod call and it is recommended to avoid using it on hot code paths.
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
|
@ -2671,6 +2673,8 @@ ngx.ctx = { foo = 32, bar = 54 }
|
|||
|
||||
When being used in the context of [init_worker_by_lua*](#init_worker_by_lua), this table just has the same lifetime of the current Lua handler.
|
||||
|
||||
The `ngx.ctx` lookup requires relatively expensive metamethod calls and it is much slower than explicitly passing per-request data along by your own function arguments. So do not abuse this API for saving your own function arguments because it usually has quite some performance impact. And because of the metamethod magic, never "local" the `ngx.ctx` table outside your function scope.
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
ngx.location.capture
|
||||
|
|
|
@ -1944,7 +1944,9 @@ Setting <code>ngx.var.Foo</code> to a <code>nil</code> value will unset the <cod
|
|||
--- use the val repeatedly later
|
||||
</geshi>
|
||||
|
||||
to prevent (temporary) memory leaking within the current request's lifetime.
|
||||
to prevent (temporary) memory leaking within the current request's lifetime. Another way of caching the result is to use the [[#ngx.ctx|ngx.ctx]] table.
|
||||
|
||||
This API requires a relatively expensive metamethod call and it is recommended to avoid using it on hot code paths.
|
||||
|
||||
== Core constants ==
|
||||
'''context:''' ''init_by_lua*, set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua, *log_by_lua*, ngx.timer.*''
|
||||
|
@ -2146,6 +2148,8 @@ Overriding <code>ngx.ctx</code> with a new Lua table is also supported, for exam
|
|||
|
||||
When being used in the context of [[#init_worker_by_lua|init_worker_by_lua*]], this table just has the same lifetime of the current Lua handler.
|
||||
|
||||
The <code>ngx.ctx</code> lookup requires relatively expensive metamethod calls and it is much slower than explicitly passing per-request data along by your own function arguments. So do not abuse this API for saving your own function arguments because it usually has quite some performance impact. And because of the metamethod magic, never "local" the <code>ngx.ctx</code> table outside your function scope.
|
||||
|
||||
== ngx.location.capture ==
|
||||
'''syntax:''' ''res = ngx.location.capture(uri, options?)''
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче