RedisLib is a library for Redis which, even though it is light and simple to use, proves itself to be powerful and efficient. It was created to facilitate the development of applications that use Redis
import br.com.rabbithole.RedisLib;
import br.com.rabbithole.configurations.RedisConfig;
import br.com.rabbithole.core.builder.Query;
import br.com.rabbithole.core.builder.commands.generics.Get;
import br.com.rabbithole.core.builder.commands.generics.sets.Set;
import br.com.rabbithole.core.builder.options.SetOptions;
import java.util.Optional;
public class Main {
public static void main(String[] args) {
//Starts a connection with Redis, passing the connection parameters
//RedisConfig(ip, port, user, password, numberOfConnections)
RedisLib.init(new RedisConfig("localhost", 6379, "user", "password", 100));
//A simple Get Query
Query<Get> getQuery = new Get.Builder()
.setKey("Foo")
.build();
//Query execution after construction
Optional<String> resultOfGetQuery = getQuery.getCommand().execute();
//A Get Query with execution in the construction
Optional<String> getQueryWithExecute = new Get.Builder()
.setKey("Foo")
.execute();
//A simple Set Query
Query<Set> setQuery = new Set.Builder()
.setKey("Foo")
.setValue("Bar")
.build();
//A Set Query with options
Query<Set> setQueryWithOptions = new Set.Builder()
.setKey("Foo")
.setValue("Bar")
.setOptions(new SetOptions.Builder()
.setExpire(100)
.setIfNotExists()
.setIfExists()
.setGet()
).build();
}
}
"Work in progress"
- Add the repo to your project
Maven:
<repository>
<id>rabbithole-repo-snapshots</id>
<name>Rabbit Hole</name>
<url>https://repo.rabbithole.com.br/snapshots</url>
</repository>
Gradle (Groovy):
maven {
url "https://repo.rabbithole.com.br/snapshots"
}
Gradle (Kotlin):
maven {
url = uri("https://repo.rabbithole.com.br/snapshots")
}
- Add the dependency
Maven:
<dependency>
<groupId>br.com.rabbithole</groupId>
<artifactId>RedisLib</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
Gradle (Groovy):
implementation "br.com.rabbithole:RedisLib:2.0.0-SNAPSHOT"
Gradle (Kotlin):
implementation("br.com.rabbithole:RedisLib:0.0.0-SNAPSHOT")
Felipe Ros Segundo Simão OS 2023 - RedisLib
2.0.0