Hi Phillippe
thanks for the question. Yes, TimeOfDay sounds like what you want for the ExpirySettings
I’m not clear on what you are thinking when you say “cache locale”. Maybe you can elaborate on how you want the cache to behave.
The cache in Apigee Edge is pretty flexible, and maybe more flexible than you need it to be. But one thing it does not have is a locale scope.
Caches are scoped per-environment. An environment is… an administrative abstraction that allows you to segregate proxies according to lifecycle.
some details. Each environment has its own set of virtual hosts, which listen for incoming requests. By default in Apigee Edge the vhosts get mapped to domain names so you have something like ORG-ENV.apigee.net as a domain name correspondint to a vhost for organization ORG and environment ENV. Then , your proxy can listen on that vhost, and receive and handle inbound requests on that vhost.
Named caches are provisioned per environment. So you can define cache1 in environment e1, and populate it. A Proxy deployed to environment e2 will not be able to read data from cache1 that exists in e1. But it would be able to read data from a cache named cache1 that exists in environment e2.
If you want to cache things for a specific locale, like fr-FR or fr-BE, then you can simply use that locale as an piece of the key in the PopulateCache and LookupCache policies. All key fragments are employed to create the cache key, so that if you have a lookupcache policy like this:
<LookupCache name='LC-1'>
<CacheResource>cache1</CacheResource>
<AssignTo>myflowvariable</AssignTo>
<Scope>Application</Scope>
<CacheKey>
<KeyFragment>fr-FR</KeyFragment>
<KeyFragment ref='variable1' />
</CacheKey>
</LookupCache>
… then the effective cache key is the concatenation of the Prefix (there is none in this case) and all of the Fragments. In this case the second fragment is a reference to a context variable, variable1. If variable1 holds “greeting” then the cache key is a concatenation of (‘fr-FR’, ‘greeting’) .
You can use a reference for the prefix as well. So you can do
<LookupCache name='LC-1'>
<CacheResource>cache1</CacheResource>
<AssignTo>myflowvariable</AssignTo>
<Scope>Application</Scope>
<CacheKey>
<KeyFragment ref='locale'/>
<KeyFragment ref='variable1' />
</CacheKey>
</LookupCache>
…and if the context variable locale holds ‘en-GB’ then you will get a concatenation of (‘en-GB’, ‘greeting’) for your cache key.
The same works for PopulateCache.
You cannot use the Prefix element for a “variable locale”, because Prefix does not accept a ref for that purpose.
Does this serve your needs?