mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 09:16:28 +08:00
let expiringcache and expiringkey also have expire update on containskey
This commit is contained in:
@@ -295,6 +295,55 @@ namespace OpenSim.Framework
|
||||
}
|
||||
}
|
||||
|
||||
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
|
||||
public bool Contains(TKey1 key, int expireMS)
|
||||
{
|
||||
return ContainsKey(key, expireMS);
|
||||
}
|
||||
|
||||
public bool ContainsKey(TKey1 key, int expireMS)
|
||||
{
|
||||
bool gotLock = false;
|
||||
try
|
||||
{
|
||||
try { }
|
||||
finally
|
||||
{
|
||||
m_rwLock.EnterUpgradeableReadLock();
|
||||
gotLock = true;
|
||||
}
|
||||
if(m_expireControl.ContainsKey(key))
|
||||
{
|
||||
bool gotWriteLock = false;
|
||||
try
|
||||
{
|
||||
try { }
|
||||
finally
|
||||
{
|
||||
m_rwLock.EnterWriteLock();
|
||||
gotWriteLock = true;
|
||||
}
|
||||
expireMS = (expireMS > m_expire) ? expireMS : m_expire;
|
||||
int now = (int)(Util.GetTimeStampMS() - m_startTS) + expireMS;
|
||||
|
||||
m_expireControl[key] = now;
|
||||
return true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotWriteLock)
|
||||
m_rwLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (gotLock)
|
||||
m_rwLock.ExitUpgradeableReadLock();
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetValue(TKey1 key, out TValue1 value)
|
||||
{
|
||||
bool success;
|
||||
|
||||
Reference in New Issue
Block a user