.net - With AppFabric caching, can you use concurrency methods with the local cache enabled?

I'm trying to figure out if it's possible to use the pessimistic concurrency model and the local cache at the same time.

When you've got the local cache enabled, and you use pessimistic concurrency methods like GetAndLock and PutAndUnlock, where is it that the locking/getting/putting is taking place? On the cache cluster, or in the local cache? And if it's happening on the cluster, does it automatically synchronize the changes with the local cache?

1 Answer

  1. Lori- Reply

    2020-02-21

    Yes, you can use local cache and pessimistic concurrency. In fact, you can use either concurrency because, as you hinted at in the question, all the concurrency resolution takes place in the 'master' cache. Which, if you think about it, is the only place it can take place - imagine if you had two server that had locked items in their local cache, that were unlocked at the same time - the 'master' cache wouldn't know which one was the 'true' item to then replicate round the cluster, so all the pessimistic locks/optimistic versioning checks have to happen in the centre.

    Once the concurrency resolution (of whichever model) has taken place, the local cache will be re-synchronised, but this depends on how you've configured your local cache. Locally-cached items can either timeout and be refreshed from the master, or the master can issue a notification to local caches when an item is updated. There's some discussion of this on this page, and detail on how you can configure this in your app. or web.config here.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>