QUERIES about cache

Can anyone help me in understanding the difference between the expiry we set in respective cache related polices and cache resource(set in envrionment config)?

<PopulateCache async="false" continueOnError="false" enabled="true" name="Populate-Cache-1">
    <DisplayName>Populate Cache 1</DisplayName>
    <Properties/>
    <CacheKey>
        <Prefix>empid</Prefix>
        <KeyFragment ref="empname"/>
    </CacheKey>
    <!-- Omit this element if you're using the included shared cache. -->
    <CacheResource>employeeobject</CacheResource>
    <Scope>Exclusive</Scope>
    <ExpirySettings>
        <TimeoutInSeconds>300</TimeoutInSeconds>
    </ExpirySettings>
    <Source>empdata</Source>
</PopulateCache>

Let's say cache resource refers the expiry value from environment config("employeeobject" set to expiry after 24 hours) and we have already set Expiry settings in the policy using TimeoutinSeconds whose value is 300 seconds(5min)

  1. Which expiry value is considered?
  2. will "<Source>empdata</Source>" be considered shared cache? if it is then we will have to omit cache resource elememt right? <!-- Omit this element if you're using the included shared cache. in this case the expiry setting element(timeoutinseconds) will be considered right? since we we omitted the cache resource(environment cache) --> Please confirm me
  3. Do we need to use same values for cache key's Prefix and keyfragment while writing caches(populate cache) and for reading entries(lookup),invalidating also? i believe yes..... please confirm me

Above queries might seem beginner level nonetheless i have to make myself clear about cache.

Please someone help me and also correct me if i understood it wrongly.

Thanks a lot

Thanks and Regards,

Mani

Solved Solved
0 2 210
1 ACCEPTED SOLUTION

  1. Which expiry value is considered?

The expiry (TimeoutInSeconds) in the policy will be used.

  1. will "<Source>empdata</Source>" be considered shared cache? if it is then we will have to omit cache resource elememt right? <!-- Omit this element if you're using the included shared cache. --> in this case the expiry setting element(timeoutinseconds) will be considered right? since we we omitted the cache resource(environment cache) Please confirm me

That Source element is not a cache, so it cannot be considered to be a "shared cache". The Source element specifies the context variable that the policy will use for the source data, which will be placed into cache. The "omit this element" comment applies to the CacheResource element. Check the documentation for details on what it does. The CacheResource element governs whether the policy will use a named cache resource or not. And if using a named cache resource, then the policy will utilize the metadata configured for that cache resource, including maximum number of elements, and so on. In all cases the policy TimeoutInSeconds element, if it is specified, will override the cache resource settings. You can easily test this.

  1. Do we need to use same values for cache key's Prefix and keyfragment while writing caches(populate cache) and for reading entries(lookup),invalidating also? i believe yes..... please confirm me

Yes, the Cache key is the thing that you use to address the cache item, whether reading or writing the cache. If you use a different cache key, you will be reading or writing a different element in the cache. To configure a LookupCache policy to retrieve an item that has been previously cached with PopulateCache, you must use a CacheKey in LookupCache that produces the same value as the CacheKey used in PopulateCache.

View solution in original post

2 REPLIES 2

  1. Which expiry value is considered?

The expiry (TimeoutInSeconds) in the policy will be used.

  1. will "<Source>empdata</Source>" be considered shared cache? if it is then we will have to omit cache resource elememt right? <!-- Omit this element if you're using the included shared cache. --> in this case the expiry setting element(timeoutinseconds) will be considered right? since we we omitted the cache resource(environment cache) Please confirm me

That Source element is not a cache, so it cannot be considered to be a "shared cache". The Source element specifies the context variable that the policy will use for the source data, which will be placed into cache. The "omit this element" comment applies to the CacheResource element. Check the documentation for details on what it does. The CacheResource element governs whether the policy will use a named cache resource or not. And if using a named cache resource, then the policy will utilize the metadata configured for that cache resource, including maximum number of elements, and so on. In all cases the policy TimeoutInSeconds element, if it is specified, will override the cache resource settings. You can easily test this.

  1. Do we need to use same values for cache key's Prefix and keyfragment while writing caches(populate cache) and for reading entries(lookup),invalidating also? i believe yes..... please confirm me

Yes, the Cache key is the thing that you use to address the cache item, whether reading or writing the cache. If you use a different cache key, you will be reading or writing a different element in the cache. To configure a LookupCache policy to retrieve an item that has been previously cached with PopulateCache, you must use a CacheKey in LookupCache that produces the same value as the CacheKey used in PopulateCache.

Thank you very much @dino for such a nice explanation,

however i struck up with "shared cache" in the cache related policies. Would you please help me in this aspect too?