Use $_ENV in the new Cache Time setting

I’m trying to use environment variable with the new redis cache feature on api action.

I have a simple action that return a database query with multiple records and I want to cache this. When I put 10 in the ‘Cache Time’ setting and call the api the cache is working and during 10 seconds the api return from the cache.

If I want to move this value (10) to docker compose environment section to handle different cache time between dev / staging / production and use $_ENV in the api setting like this:

app/api/translations.json:

{
  "settings": {
    "options": {
      "ttl": "{{$_ENV.TRANSLATIONS_CACHE_TIME.toNumber()}}"
    }
  },
  ...
}

No error is shown but the cache feature doesn’t work after that, any idea ?

1 Like

At this moment all settings are static, will see if it is possible to make them dynamic.

1 Like

Thanks for your answer. It would be awesome if the settings could be dynamic so I can set the cache time to 86400 (one day) in production for example but have a lower setting for development where cache is more a pain than a gain.

2 Likes