2

The documentation states:

If forceLock is true, key is locked irrespective of key-value pair presence in cache.

With no further explanation, e.g. what it means to have a lock on a key that is not in the cache and what the intended technique is (or are) for inserting a cache item within the lock.

redcalx
  • 8,177
  • 4
  • 56
  • 105

2 Answers2

1

From my past experiences, it is used to reserve a key in the cache by a client.

As you may know, Lock methods are suitable for Resource Data : Shared Memory, concurrently read and written into, accessed by a large number of transactions, such as auction items.

If the key does not exist you can lock the key if it's the first thread/client in and have other threads spin and wait until DataCacheErrorCode.ObjectLocked error code goes away.

Cybermaxs
  • 24,378
  • 8
  • 83
  • 112
0

this is what intended for appfabric pattern.

this.Cache.GetAndLock<ICollection<string>>(key, new TimeSpan(0, 0, 30)

you can use generic parameters for fetching the cache item.

Manoj Patil
  • 970
  • 1
  • 10
  • 19