NamedCache cannot refresh lock using AcquireLock from a different thread


I'm using .NET 4.7.2, soss_svcdotnet, and soss_namedchache Per documentation, calling AcquireLock(string) "
on an instance of the NamedCache that already has a lock on the cached object will reset the 90 second lock timeout." However, when I use the same NamedCache instance in a new thread, I get "Soss.Client.ObjectLockedException: 'Unable to acquire lock while retrieving object. Object Key: TEST'". This exception is thrown when the object is locked by another "client". How is the same instance of NamedCache considered a different client?

See sample code below
const string TEST_KEY = "TEST";
var nc = CacheFactory.GetCache("Scenario2");
nc.MaxLockAttempts = 1;
nc.Insert(TEST_KEY, "blah", new CreatePolicy(), false, false);

new Thread(() =>


Staff member
Hi Caleb,

Great question. In the NamedCache library, locks are held on a per-thread basis. (Behind the scenes, the API holds on to a lock ticket for you in thread-local storage.) The idea is that locks can provide consistency across any number of clients, processes, and threads.

FYI, the newer Scaleout.Client library uses a different design to better support async programming (it's possible for an async method to continue on a different thread after awaiting). Locking calls in Scaleout.Client explicitly return a lock token that callers must provide to subsequent operations on the object (GetExclusiveLockAsync, for example). You could conceivably share that token across threads/tasks (but be very, very careful since you could easily undermine the consistency that a lock provides).
Last edited: