Programming API
ZoneCache
The ZoneCache is used to store data in a shared cache, typically local to the Zone your gateway is running (for example, the same data center). This can be used to store small, simple objects. It's excellent for improving the latency of your gateway if you need to access remote data in your policies, such as calling another API in a policy.
There's an demonstration of ZoneCache use in the Per User Rate Limits Using a Database example.
Constructing the Cache#
Reading from the Cache#
Writing to the Cache#
When writing to the cache the data
parameters will be JSON serialized. If your
data does not serialize cleanly to JSON (like the Headers
object does not) you
won't be able to read your data back/
Deleting from the Cache#
TIP On some code paths you may not want to await
the cache to wait for the
operation to complete. For example, when writing data you may choose to write
asynchronously. However, we recommend catching errors if you do this, for
example: