The change in v7 that fixes things:
- scache.cacheBlock(blockName, cachedItem); // if this
- // fails, due to
- // block already
- // being there, exception will be thrown
- backingStore.put(blockName, scache);
+ /This will throw a runtime exception if we try to cache the same value twice/
+ scache.cacheBlock(blockName, cachedItem);
+ /Spinlock, if we're spinlocking, that means an eviction hasn't taken place yet/
+ while (backingStore.putIfAbsent(blockName, scache) != null)
The test failed when the following occurred:
Both SSC and SC have the same contents:
Item A is in both SSC and SC.
Thread A: evicts A from ssc.
Thread B: starts doing a put into thread SC, -
Thread B: gets directed into SSC, starts doing put in SSC,
Thread B: put goes through thanks to the occuring eviction.
Thread A: calls evictor on SC, removing the object from SlabCache.
result: Object is in SSC, but not SC.