Best way to Invalidate Cache.

Invalidate Cache:

------------------------

I have a Scenario that when user went login i need to cache data based on dropdown (pre,post,all)

Key =pre,

Key =post,

key =all,

some time user may or may not go through all 3 options but when user creating new order that time i need to invalidate all 3 cache beacause i don't no which time the order will list(pre (or) post (or) all) as now it working but suggest me the good way to handle this scenario.

0 1 373
1 REPLY 1

There is an InvalidateCache policy.

If you have three items to cache, I suppose you can use three distinct cache keys.

If you want to invalidate those cache items, call the InvalidateCache policy with those three distinct keys. eg

<InvalidateCache name="CacheInvalidate-1">
    <CacheKey>
        <Prefix>statedata-pre</Prefix>
        <KeyFragment ref="username"/>
    </CacheKey>
     ...

And

<InvalidateCache name="CacheInvalidate-2">
    <CacheKey>
        <Prefix>statedata-post</Prefix>
        <KeyFragment ref="username"/>
    </CacheKey>
     ...

Etc.

Am I answering the question?