Interface PluginKeyValueStore
public interface PluginKeyValueStore
Simple key-value store for plugin configuration and small data.
This provides a simpler alternative to defining schemas for plugins that just need to store configuration values or small pieces of data.
All keys are namespaced to the plugin automatically.
Example:
PluginKeyValueStore store = db.getKeyValueStore();
// Store values
store.set("api_key", "abc123");
store.set("max_retries", 5);
store.set("features_enabled", true);
// Retrieve values
String apiKey = store.getString("api_key").orElse("default");
int maxRetries = store.getInt("max_retries").orElse(3);
boolean enabled = store.getBoolean("features_enabled").orElse(false);
// Guild/User scoped values
store.set("guild:123456:prefix", "!");
store.set("user:789:theme", "dark");
-
Method Summary
Modifier and TypeMethodDescriptionlongcount()Count the number of stored key-value pairs.booleanDelete a key.intdeleteByPrefix(String prefix) Delete multiple keys by prefix.booleanCheck if a key exists.getAll()Get all key-value pairs.Get all key-value pairs matching a prefix.getBoolean(String key) Get a boolean value.default booleangetBoolean(String key, boolean defaultValue) Get a boolean value with a default.Get a double value.default doubleGet a double value with a default.Get an integer value.default intGet an integer value with a default.Get a long value.default longGet a long value with a default.Get a string value.default StringGet a string value with a default.keys()Get all keys.Get all keys matching a prefix.voidSet a boolean value.voidSet a double value.voidSet an integer value.voidSet a long value.voidSet a string value.voidSet multiple values at once.
-
Method Details
-
set
-
set
-
set
-
set
Set a boolean value.- Parameters:
key- the keyvalue- the value
-
set
-
getString
-
getString
-
getInt
-
getInt
Get an integer value with a default.- Parameters:
key- the keydefaultValue- default if not present- Returns:
- the value or default
-
getLong
-
getLong
Get a long value with a default.- Parameters:
key- the keydefaultValue- default if not present- Returns:
- the value or default
-
getBoolean
-
getBoolean
Get a boolean value with a default.- Parameters:
key- the keydefaultValue- default if not present- Returns:
- the value or default
-
getDouble
-
getDouble
Get a double value with a default.- Parameters:
key- the keydefaultValue- default if not present- Returns:
- the value or default
-
exists
-
delete
Delete a key.- Parameters:
key- the key- Returns:
- true if deleted, false if didn't exist
-
deleteByPrefix
Delete multiple keys by prefix.- Parameters:
prefix- the key prefix- Returns:
- number of keys deleted
-
keys
-
keys
-
getAll
-
getAll
-
setAll
-
count
long count()Count the number of stored key-value pairs.- Returns:
- count of entries
-