Class QueryExecutor
java.lang.Object
com.github.darksoulq.abyssallib.common.database.nosql.redis.QueryExecutor
Provides a high-level API for executing standard Redis commands.
This class handles resource management (try-with-resources) for every call and provides both synchronous and asynchronous variants of common commands.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes one or more keys.Deletes keys asynchronously.booleanChecks if a key exists in the database.voidSets a timeout on a key.Retrieves the value of a key.Gets a key value asynchronously.voidDeletes fields from a hash.Gets a field value from a hash.Retrieves all fields and values from a hash.hgetAllAsync(String key) Gets all fields from a hash asynchronously.Gets a hash field value asynchronously.voidSets a field in a Redis hash.voidSets multiple fields in a Redis hash using a map.Sets a hash field asynchronously.voidPushes values to the front (left) of a list.Retrieves a range of elements from a list.pipeline()Creates a new PipelineExecutor for batching operations starting from this executor.voidPushes values to the end (right) of a list.voidAdds members to a set.voidSets a key to a specific value.Sets a key value asynchronously.voidSets a key with an expiration time.booleanChecks if a value is a member of a set.Retrieves all members of a set.
-
Constructor Details
-
QueryExecutor
Constructs a new QueryExecutor.- Parameters:
database- The targetDatabase.
-
-
Method Details
-
set
Sets a key to a specific value.- Parameters:
key- The key name.value- The string value.
-
setex
Sets a key with an expiration time.- Parameters:
key- The key name.seconds- TTL in seconds.value- The string value.
-
get
Retrieves the value of a key.- Parameters:
key- The key name.- Returns:
- The string value, or null if not found.
-
del
Deletes one or more keys.- Parameters:
keys- The keys to remove.
-
hset
Sets a field in a Redis hash.- Parameters:
key- The hash key.field- The field name.value- The value.
-
hset
Sets multiple fields in a Redis hash using a map.- Parameters:
key- The hash key.hash- The map of fields and values.
-
hget
Gets a field value from a hash.- Parameters:
key- The hash key.field- The field name.- Returns:
- The value, or null.
-
hgetAll
Retrieves all fields and values from a hash.- Parameters:
key- The hash key.- Returns:
- A map of all entries in the hash.
-
hdel
Deletes fields from a hash.- Parameters:
key- The hash key.fields- The fields to delete.
-
lpush
Pushes values to the front (left) of a list.- Parameters:
key- The list key.values- The values to push.
-
rpush
Pushes values to the end (right) of a list.- Parameters:
key- The list key.values- The values to push.
-
lrange
Retrieves a range of elements from a list.- Parameters:
key- The list key.start- The start index (0-based).stop- The end index.- Returns:
- A list of strings within the range.
-
sadd
Adds members to a set.- Parameters:
key- The set key.members- The members to add.
-
smembers
Retrieves all members of a set.- Parameters:
key- The set key.- Returns:
- A set of members.
-
sismember
Checks if a value is a member of a set.- Parameters:
key- The set key.member- The value to check.- Returns:
- True if the member exists in the set.
-
exists
Checks if a key exists in the database.- Parameters:
key- The key to check.- Returns:
- True if it exists.
-
expire
Sets a timeout on a key.- Parameters:
key- The key.seconds- Timeout in seconds.
-
setAsync
Sets a key value asynchronously.- Returns:
- A future.
-
getAsync
Gets a key value asynchronously.- Returns:
- A future containing the string.
-
hsetAsync
Sets a hash field asynchronously.- Returns:
- A future.
-
hgetAsync
Gets a hash field value asynchronously.- Returns:
- A future containing the string.
-
hgetAllAsync
Gets all fields from a hash asynchronously.- Returns:
- A future containing the map.
-
delAsync
Deletes keys asynchronously.- Returns:
- A future.
-
pipeline
Creates a new PipelineExecutor for batching operations starting from this executor.- Returns:
- A new
PipelineExecutor.
-