You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Increments the (numerical) value for `key` in the shm-based dictionary [ngx.shared.DICT](#ngxshareddict) by the step value `value`. Returns the new resulting number if the operation is successfully completed or `nil` and an error message otherwise.
6277
6277
6278
-
The key must already exist in the dictionary, otherwise it will return `nil` and `"not found"`.
6278
+
When the key does not exist or has already expired in the shared dictionary,
6279
+
6280
+
1. if the `init` argument is not specified or takes the value `nil`, this method will return `nil` and the error string `"not found"`, or
6281
+
1. if the `init` argument takes a number value, this method will create a new `key` with the value `init + value`.
6282
+
6283
+
Like the [add](#ngxshareddictadd) method, it also overrides the (least recently used) unexpired items in the store when running out of storage in the shared memory zone.
6284
+
6285
+
The `forcible` return value will always be `nil` when the `init` argument is not specified.
6286
+
6287
+
If this method succeeds in storing the current item by forcibly removing other not-yet-expired items in the dictionary via LRU, the `forcible` return value will be `true`. If it stores the item without forcibly removing other valid items, then the return value `forcible` will be `false`.
6279
6288
6280
6289
If the original value is not a valid Lua number in the dictionary, it will return `nil` and `"not a number"`.
6281
6290
6282
-
The `value` argument can be any valid Lua numbers, like negative numbers or floating-point numbers.
6291
+
The `value` argument and `init` argument can be any valid Lua numbers, like negative numbers or floating-point numbers.
6283
6292
6284
-
This feature was first introduced in the `v0.3.1rc22` release.
6293
+
This method was first introduced in the `v0.3.1rc22` release.
6294
+
6295
+
The optional `init` parameter was first added in the `v0.10.6` release.
Increments the (numerical) value for <code>key</code> in the shm-based dictionary [[#ngx.shared.DICT|ngx.shared.DICT]] by the step value <code>value</code>. Returns the new resulting number if the operation is successfully completed or <code>nil</code> and an error message otherwise.
5262
5262
5263
-
The key must already exist in the dictionary, otherwise it will return <code>nil</code> and <code>"not found"</code>.
5263
+
When the key does not exist or has already expired in the shared dictionary,
5264
+
5265
+
# if the <code>init</code> argument is not specified or takes the value <code>nil</code>, this method will return <code>nil</code> and the error string <code>"not found"</code>, or
5266
+
# if the <code>init</code> argument takes a number value, this method will create a new <code>key</code> with the value <code>init + value</code>.
5267
+
5268
+
Like the [[#ngx.shared.DICT.add|add]] method, it also overrides the (least recently used) unexpired items in the store when running out of storage in the shared memory zone.
5269
+
5270
+
The <code>forcible</code> return value will always be <code>nil</code> when the <code>init</code> argument is not specified.
5271
+
5272
+
If this method succeeds in storing the current item by forcibly removing other not-yet-expired items in the dictionary via LRU, the <code>forcible</code> return value will be <code>true</code>. If it stores the item without forcibly removing other valid items, then the return value <code>forcible</code> will be <code>false</code>.
5264
5273
5265
5274
If the original value is not a valid Lua number in the dictionary, it will return <code>nil</code> and <code>"not a number"</code>.
5266
5275
5267
-
The <code>value</code> argument can be any valid Lua numbers, like negative numbers or floating-point numbers.
5276
+
The <code>value</code> argument and <code>init</code> argument can be any valid Lua numbers, like negative numbers or floating-point numbers.
5268
5277
5269
-
This feature was first introduced in the <code>v0.3.1rc22</code> release.
5278
+
This method was first introduced in the <code>v0.3.1rc22</code> release.
5279
+
5280
+
The optional `init` parameter was first added in the <code>v0.10.6</code> release.
0 commit comments