Constructs a new instance of the class with the specified collection name and initializes a connection.
The name of the collection to be used.
Represents a client instance for interacting with a Redis database.
This client
variable is an instance of the RedisClientType
class, which provides the ability
to execute operations on the Redis server. It supports default Redis commands, custom modules,
user-defined functions, and scripts.
Type Parameters:
The client can be used for performing various Redis operations like getting, setting, or modifying data. It also allows the execution of custom functions and scripts, providing a flexible and powerful interface to work with Redis.
Establishes a connection to the Redis database. If a connection already exists and is open, it resolves the existing client instance. Otherwise, it initializes and connects a new Redis client.
Optional
first: boolean = falseOptional flag indicating whether it is the first connection attempt.
A promise that resolves with the active Redis client instance.
Creates a new entry in the specified collection in the database.
The name of the collection where the data should be inserted.
The data object to be stored, containing a key and value.
A promise that resolves to the inserted data object if successful, or null if an error occurs.
Deletes a specific key from the specified collection in the database.
The name of the collection from which the key needs to be deleted.
The key to be deleted from the collection.
A promise that resolves to true if the key was deleted successfully, or false if an error occurred.
Disconnects the client if it is currently connected. This method ensures that the client is safely disconnected and sets the client instance to null.
Does not return any value.
Retrieves all matching documents from the specified collection based on the provided query and bindings.
The name of the collection to query.
The query string used to filter the results.
Optional parameters to bind within the query for dynamic filtering.
A promise that resolves to an array of objects of type T matching the query criteria.
Fetches a single record from the specified collection that matches the given query and binding values.
The name of the collection to search.
The query string used to find the record.
Optional parameters to be bound to the query placeholders.
A promise that resolves with the found record or rejects if no record matches.
Retrieves all documents from the specified collection.
The name of the collection to retrieve documents from.
A promise that resolves to an array of documents of type T.
Retrieves a value from the Redis database by its key.
The name of the collection or namespace in the Redis database.
The key of the item to retrieve from the specified collection.
A promise that resolves to the retrieved value and its key, or null if an error occurs during retrieval.
Performs necessary cleanup when the component or object is destroyed. This includes disconnecting any active connections or listeners to prevent memory leaks and ensure proper resource management.
Does not return a value.
Updates a specific record in the given collection with the provided data.
The name of the collection where the update will be performed.
The data object that will be used to update the record in the collection.
A promise that resolves to the updated record.
Injectable service that provides methods for interacting with a Redis database. This class implements the
Instance
andConnector
interfaces and offers CRUD operations as well as connection management for Redis.