public class Users extends Object
| Modifier and Type | Method and Description |
|---|---|
static CacheManager |
cacheManager()
The Cache Manager that handles Users.
|
static void |
clean()
Cleans the internal cache, by removing the users that have expired.
|
static void |
clear()
The full User cache is cleared, no User is kept.
|
static Optional<User> |
get(int id)
Retrieves a user from the database.
|
static Optional<User> |
getCached(int id)
Retrieves the user corresponding to a provided ID from the cache.
|
static void |
init()
Prepares this class to serve Users.
|
static boolean |
isMyID(int id) |
static LoggedUser |
me()
The user that is connected to the API.
|
static OptionalInt |
myID() |
static void |
reset()
Resets the stored data of this class, that is dependent on the logged-in user.
|
public static Optional<User> get(int id)
If the user is in the cache, it is returned. If the user is not in the cache, this method stalls and queries the server. If the user is in the cache but has expired, it is returned and a concurrent update job starts.
Note that this API is written so that IDs are not needed for the typical user.
This method intentionally doesn't throw any exceptions, because it is designed to be used in a concurrent
fashion. If any occurs, they are sent to the exceptions handlers, see
Internal.setCantConnectHandler(Consumer).
id - the ID of the user.Same, but without querying the serverpublic static Optional<User> getCached(int id)
this method.
This method will not query the server in any way. It only returns the contents of the cache for that specific ID.
As a side effect, this method will not update the user either. This means that the User's inherent timer
(see the Descriptor class for more information) will not be reset, as
this does not count as a usage of the User.
id - the ID of the user.Same, but queries the server is the user is not found in the cache.public static LoggedUser me()
public static void clear()
public static void clean()
public static void reset()
public static void init()
throws Request.CantConnectException
Request.CantConnectException - if no connection to the server can be established.public static boolean isMyID(int id)
public static OptionalInt myID()
public static CacheManager cacheManager()