Define a Custom Cache

You define a custom cache in a cartridge using a JSON file. You can have up to 100 custom caches across all cartridges in a code version. Any cartridge within a code version can access all the caches defined in all the cartridges of that code version.

You reference the path of the cache definition JSON file in the cartridge's package.json file. The path is relative to the directory where the package.json is located. For example, this entry in the package.json file specifies that the custom caches for the cartridge are defined in a file named caches.json that is in the same directory as the package.json file.

"caches": "./caches.json"

You assign each cache an ID that is unique across all cartridges in a code version. If you use an ID in more than one cartridge in the code version, the cache isn't enabled and an error is logged. You can optionally specify the maximum number of seconds an entry is retained in the cache. This JSON file defines two custom caches: UnlimitedTestCache, which doesn't have an expiration time, and TestCacheWithExpiration, which has an expiration time of 10 seconds.

  "caches": [
      "id": "UnlimitedTestCache"
      "id": "TestCacheWithExpiration",
      "expireAfterSeconds": 10

Problems with invalid cache definitions are reported in the custom error log. If you change a cache definition file or activate a new code version, the content for all caches in the code version is cleared.