Package com.google.gerrit.server.account
Class AccountCacheImpl
- java.lang.Object
-
- com.google.gerrit.server.account.AccountCacheImpl
-
- All Implemented Interfaces:
AccountCache
public class AccountCacheImpl extends Object implements AccountCache
Caches important (but small) account state to avoid database hits.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
evict(Account.Id accountId)
Evicts the account from the cache and triggers a reindex for it.void
evictAllNoReindex()
Evict all accounts from the cache, but doesn't trigger reindex of all accounts.AccountState
get(Account.Id accountId)
Returns anAccountState
instance for the given account ID.AccountState
getByUsername(String username)
Returns anAccountState
instance for the given username.AccountState
getOrNull(Account.Id accountId)
Returns anAccountState
instance for the given account ID.static com.google.inject.Module
module()
-
-
-
Method Detail
-
module
public static com.google.inject.Module module()
-
get
public AccountState get(Account.Id accountId)
Description copied from interface:AccountCache
Returns anAccountState
instance for the given account ID. If not cached yet the account is loaded. Returns an emptyAccountState
instance to represent a missing account.- Specified by:
get
in interfaceAccountCache
- Parameters:
accountId
- ID of the account that should be retrieved- Returns:
AccountState
instance for the given account ID, if no account with this ID exists an emptyAccountState
instance is returned to represent the missing account
-
getOrNull
public AccountState getOrNull(Account.Id accountId)
Description copied from interface:AccountCache
Returns anAccountState
instance for the given account ID. If not cached yet the account is loaded. Returnsnull
if the account is missing.- Specified by:
getOrNull
in interfaceAccountCache
- Parameters:
accountId
- ID of the account that should be retrieved- Returns:
AccountState
instance for the given account ID, if no account with this ID existsnull
is returned
-
getByUsername
public AccountState getByUsername(String username)
Description copied from interface:AccountCache
Returns anAccountState
instance for the given username.This method first loads the external ID for the username and then uses the account ID of the external ID to lookup the account from the cache.
- Specified by:
getByUsername
in interfaceAccountCache
- Parameters:
username
- username of the account that should be retrieved- Returns:
AccountState
instance for the given username, if no account with this username exists or if loading the external ID failsnull
is returned
-
evict
public void evict(Account.Id accountId) throws IOException
Description copied from interface:AccountCache
Evicts the account from the cache and triggers a reindex for it.- Specified by:
evict
in interfaceAccountCache
- Parameters:
accountId
- account ID of the account that should be evicted- Throws:
IOException
- thrown if reindexing fails
-
evictAllNoReindex
public void evictAllNoReindex()
Description copied from interface:AccountCache
Evict all accounts from the cache, but doesn't trigger reindex of all accounts.- Specified by:
evictAllNoReindex
in interfaceAccountCache
-
-