let expiringcache and expiringkey also have expire update on containskey

This commit is contained in:
UbitUmarov
2020-08-17 15:51:48 +01:00
parent 6dcb4ed7a0
commit 1b9cdbbe40
2 changed files with 92 additions and 0 deletions

View File

@@ -259,6 +259,49 @@ namespace OpenSim.Framework
}
}
public bool ContainsKey(Tkey1 key, int expireMS)
{
bool gotLock = false;
try
{
try { }
finally
{
m_rwLock.EnterUpgradeableReadLock();
gotLock = true;
}
if (m_dictionary.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_dictionary[key] = now;
return true;
}
finally
{
if (gotWriteLock)
m_rwLock.ExitWriteLock();
}
}
return false;
}
finally
{
if (gotLock)
m_rwLock.EnterUpgradeableReadLock();
}
}
public bool TryGetValue(Tkey1 key, out int value)
{
bool success;