Repository navigation
Caching
To enhance API performance, frequently accessed data is stored using the QueryConfig class within the Ts3ServerQuery.
This approach reduces repetitive data fetching, making operations more efficient.
This is achieved simply by utilizing the QueryConfig class along with its getter method within the Ts3ServerQuery class.
By adding Enums with in the addCacheItem Method to
the cache list you can exactly choose what type of objects retrieved
by the API you want to store.
If enabled the query will collect the specified information when connecting
to the Teamspeakserver (selectVirtualServer Method), be aware of this because it
could increase the time needed to connect to a server.
Methods that return cached objects are in the Ts3BasicAPI (and consequently in the Ts3SyncAPI), specifically methods with return values starting with "get".
CacheType Enum (List of Enums to choose from):
public enum CacheType {
CLIENTS, CHANNELS, GROUPS, DATABASE, PERMISSION, QUERY, VIRTUALSERVER;
}Status means how likely the cached Data will be up to date. Recommended means there is no disadvantage instead of the normal Method.
Methods are from the Ts3BasicAPI, but also include the Ts3SyncAPI because it is a subclass.
Updated means when the stored data (like a channel or client) is updated by the api itself.
Stores information about every single client and the clientlist.
Methods: getClient(), getClients()
Updated: ClientJoinEvent, ClientLeaveEvent and ClientMoveEvent
Stores information about every single channel and the channellist.
Methods: getChannel(), getChannels()
Updated: ChannelCreateEvent, ChannelDeletedEvent, ChannelEditedEvent and ChannelMovedEvent
Not updated: ChannelDescriptionEditedEvent and ChannelPasswordChangedEvent because it is included in ChannelEditedEvent.
Stores information about the servergrouplist and the channelgrouplist.
Methods: getServerGroups(), getChannelGroups()
Updated: This is not updated by the api itself, you can turn it off temporary
to get updated information or update it by yourself.
(Using the Method Ts3ServerQuery#getCache().updateServerGroupsCache() or
Ts3ServerQuery#getCache().updateChannelGroupsCache().)
Stores information about the databaseclients and the databaseclientlist.
Methods: getDataBaseClientInfo(), getDatabaseClients()
Updated: ClientJoinEvent, ClientLeaveEvent (only if Client Caching is enabled)
Stores information about the permissionslist like permissionid, permissionname or permissiondescription
Status: Recommended
Methods: getPermissionList()
Updated: This is not updated by the api itself, you can turn it off temporary to get updated information or update it by yourself (definitely not needed).
Stores information about the Serverquery. (Recommended to use because beside the ChannelID and the Nickname there is no information that needs an update.)
Status: Recommended
Methods: getQueryInfo()
Updated: ClientMoveEvent (when the Query moves) and 'Ts3BasicAPI#updateQueryName()' if the Nickname is updated.
Stores information about the virtualserver and his properties.
Methods: getServerInfo() and getVirtualServers()
Updated: ServerEditedEvent
public class Test {
public static void main(String[] args) {
Ts3ServerQuery query = new Ts3ServerQuery();
query.getConfig().addCacheItem(CacheType.PERMISSION);
query.getConfig().addCacheItem(CacheType.CHANNELS);
query.getConfig().addCacheItem(CacheType.GROUPS);
query.getConfig().addCacheItem(CacheType.CLIENTS);
try {
query.connect("hostname", 10011, "Username", "Passwort", 1, "Ts³-Bot", 1);
} catch (IOException | QueryLoginException e) {
e.printStackTrace();
}
query.stopQuery();
}
}