@@ -78,6 +78,7 @@ The protocol expose commands to interact with the distributed storage :
78
78
- TOUCH : update the ttl of a key
79
79
- DELETE : delete a key from the storage
80
80
- INCR : increment the value for a key
81
+ - RATE_LIMITER : consume a token in the sliding window rate limiter identified by the key
81
82
82
83
In a clustered deployment (2 or more instances), a client need to connect to only one instance to see all the storage.
83
84
The goal is to provide a near storage associated with a nginx instance.
@@ -136,42 +137,41 @@ named hazelcast.xml.
136
137
This is an example of this file :
137
138
138
139
``` xml
139
-
140
- <hazelcast xsi : schemaLocation =" http://www.hazelcast.com/schema/config hazelcast-config-3.9.xsd "
140
+ <? xml version = " 1.0 " encoding = " UTF-8 " ?>
141
+ <hazelcast xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance "
141
142
xmlns =" http://www.hazelcast.com/schema/config"
142
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance " >
143
- < group >
144
- < name >ngx-dshm</ name >
145
- < password >FIXME</ password >
146
- </ group >
143
+ xsi : schemaLocation =" http://www.hazelcast.com/schema/config
144
+ http://www.hazelcast.com/schema/config/hazelcast-config-5.0.xsd " >
145
+
146
+ < cluster-name >ngx-dshm</ cluster-name >
147
+
147
148
<network >
148
149
<port auto-increment =" false" >5701</port >
149
150
<join >
150
151
<multicast enabled =" false" />
151
152
<tcp-ip enabled =" true" >
152
- <interface >10 .0.x.y </interface >
153
+ <interface >127 .0.0.1 </interface >
153
154
<member-list >
154
- <member >10.0.x.y:5701</member >
155
- <member >10.0.x.z:5701</member >
155
+ <member >127.0.0.1</member >
156
156
</member-list >
157
157
</tcp-ip >
158
158
<aws enabled =" false" />
159
159
</join >
160
160
</network >
161
+
161
162
<map name =" default" >
162
163
<in-memory-format >BINARY</in-memory-format >
163
164
<backup-count >1</backup-count >
164
165
<async-backup-count >0</async-backup-count >
165
166
<time-to-live-seconds >0</time-to-live-seconds >
166
167
<max-idle-seconds >0</max-idle-seconds >
167
- <eviction-policy >NONE</eviction-policy >
168
- <max-size policy =" PER_NODE" >0</max-size >
169
- <eviction-percentage >25</eviction-percentage >
170
- <min-eviction-check-millis >100</min-eviction-check-millis >
171
- <merge-policy >com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy >
168
+ <eviction eviction-policy =" NONE" />
169
+ <merge-policy >PutIfAbsentMergePolicy</merge-policy >
172
170
<cache-deserialized-values >INDEX-ONLY</cache-deserialized-values >
173
171
</map >
172
+
174
173
</hazelcast >
174
+
175
175
```
176
176
177
177
The reference documentation for this configuration is
@@ -363,6 +363,27 @@ INCR key -1 0\r\n
363
363
INCR key -1 0 60\r\n
364
364
```
365
365
366
+ ** _ RATE_LIMITER \< key\> \< capacity\> \< duration\> _ **
367
+
368
+ ** with data:** _ no_
369
+
370
+ Consumes a token in a sliding window rate limiter with the key ` key ` . The sliding window duration is configured with ` duration ` seconds. The
371
+ rate limiter is created automatically
372
+
373
+ The command attempts to consume a token and return the number of remaining available tokens. If there were no more tokens available, the
374
+ command returns -1, otherwise
375
+ the command return the number of tokens available between 0 and ` capacity `
376
+
377
+ note : GET command with this key return the available tokens
378
+
379
+ This operation is atomic.
380
+
381
+ Example : consumes a token in rate limiter ` key ` with capacity 1000 tokens every 10 seconds
382
+
383
+ ```
384
+ RATE_LIMITER key 1000 10\r\n
385
+ ```
386
+
366
387
** _ FLUSHALL [ region] _ **
367
388
368
389
** with data:** _ no_
@@ -460,10 +481,10 @@ The session_storage parameter control the storage module to be used.
460
481
- An official docker image build is available at quay.io or directly in the GitHub registry :
461
482
462
483
``` shell
463
- docker pull quay.io/grrolland/ngx-distributed-shm
484
+ docker pull quay.io/grrolland/ngx-distributed-shm
464
485
```
465
486
` ` ` shell
466
- docker pull ghcr.io/grrolland/ngx-distributed-shm
487
+ docker pull ghcr.io/grrolland/ngx-distributed-shm
467
488
` ` `
468
489
469
490
# # Kubernetes
0 commit comments