How to configure a cache locale and timezone

Not applicable

Hi everyone,

I just started evaluating Apigee to see if I can use it to replace a custom made gateway service.

Specifically, I'm trying to configure a response cache that expires at the same time everyday. It looks like ExpirySettings/TimeOfDay is the way to go. However, now I want to configure the timezone that applies to this time.

The doc invites me to create an environment cache. But it doesn't contain anything about configuring the cache locale and timezone. It actually contains a link to itself 🙂

So can someone please send me to a page which explains how to configure a cache locale and timezone?

Thanks.

1 2 424
2 REPLIES 2

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?

Hi Dino and thanks for taking to answer my question. I can see why it wasn't very clear so here are some details (I cannot edit my question somehow...).

I'm trying to configure a response cache that expires at the same time everyday. I need to configure the time at a specific timezone. Unfortunately the documentation is not clear on that:

For the time of day, the default locale and time zone will vary depending on where the code is running (which isn't knowable when you configure the policy). For information on configuring your locale, see Creating and editing an environment cache.

But this page doesn't contain anything about configuring the cache locale and timezone. It actually contains the same paragraph that I cited, with a link to itself.

As you suggested, I looked into the environment configuration but couldn't find anything about the timezone in there either.

Do you know anything about configuring a timezone in an environment or a cache?