You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public V get(K key, boolean isUpdateLastAccess);
public void put(K key, V object, long timeout);
ReentrantCache类在get方法中通过缩小锁粒度来提高性能,即只有获取缓存对象和移除缓存对象时才加锁;
问题是:是否可能执行到判断缓存对象是否过期这一步时,另一线程通过put方法放一个相同个key但不同对象的缓存,进而导致误删。
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
public V get(K key, boolean isUpdateLastAccess);
public void put(K key, V object, long timeout);
ReentrantCache类在get方法中通过缩小锁粒度来提高性能,即只有获取缓存对象和移除缓存对象时才加锁;
问题是:是否可能执行到判断缓存对象是否过期这一步时,另一线程通过put方法放一个相同个key但不同对象的缓存,进而导致误删。
原代码如下:
Beta Was this translation helpful? Give feedback.
All reactions