void CPermissionsCache::add(ISecUser& sec_user) { if(!isCacheEnabled() || &sec_user == NULL) return; const char* username = sec_user.getName(); if(!username || !*username) return; synchronized block(m_userCacheMonitor); CachedUser* user = m_userCache[username]; if(user) { m_userCache.erase(username); delete user; } m_userCache[username] = new CachedUser(sec_user.clone()); }
void CPermissionsCache::add(ISecUser& sec_user) { if(!isCacheEnabled()) return; const char* username = sec_user.getName(); if(!username || !*username) return; synchronized block(m_userCacheMonitor); string key(username); MapUserCache::iterator it = m_userCache.find(key); CachedUser* user = NULL; if (it != m_userCache.end()) { user = (CachedUser*)(it->second); m_userCache.erase(username); delete user; } m_userCache[username] = new CachedUser(sec_user.clone()); }
void CPermissionsCache::add(ISecUser& sec_user) { if(!isCacheEnabled()) return; const char* username = sec_user.getName(); if(!username || !*username) return; string key(username); WriteLockBlock writeLock(m_userCacheRWLock ); MapUserCache::iterator it = m_userCache.find(key); CachedUser* user = NULL; if (it != m_userCache.end()) { user = (CachedUser*)(it->second); m_userCache.erase(username); delete user; } #ifdef _DEBUG DBGLOG("CACHE: CPermissionsCache Adding cached user %s", username); #endif m_userCache[username] = new CachedUser(sec_user.clone()); }