Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
JNoSQL/Diana/Redis
Redis
Redis is an open-source software project (sponsored by Redis Labs) that implements data structure servers. It is networked, in-memory, and stores keys with optional durability.
Maven Project
To use Redis driver in a Maven Project:
<dependency>
<groupId>org.jnosql.diana</groupId>
<artifactId>redis-driver</artifactId>
<version>version</version>
</dependency>
E.g:
<dependency>
<groupId>org.jnosql.diana</groupId>
<artifactId>redis-driver</artifactId>
<version>0.0.1</version>
</dependency>
Key Value
The Redis key-value implementation uses the RedisConfiguration to the configuration. This class has configurations methods such as host, port, timeout, user, password. Beyond the method also it can read a configuration from diana-redis.properties file.
- redis-master-host: the host client
- redis-master-port: the port, the default value 6379<
- redis-timeout: the redis timeout, the default value 2000 on milis
- redis-password: the password
- redis-database: the redis database number, the default value is 0
- redis-clientName: the redis client name
- redis-configuration-max-total: The max number of thread to {@link JedisPoolConfig}, the default value 1000
- redis-configuration-max-idle: The max idle {@link JedisPoolConfig}, the default value 10
- redis-configuration-min-idle: The min idle {@link JedisPoolConfig}, the default value 1
- redis-configuration-max--wait-millis: The max wait on millis on {@link JedisPoolConfig}, the default value 3000
Sample Code
public class App {
public static void main(String[] args) {
KeyValueConfiguration configuration = new ArangoDBKeyValueConfiguration();
try (BucketManagerFactory managerFactory = configuration.get()) {
BucketManager bucket = managerFactory.getBucketManager("bucket");
List<String> list = managerFactory.getList("bucketList", String.class);
Set<String> set = managerFactory.getSet("bucketSet", String.class);
Map<String, Integer> map = managerFactory.getMap("bucketList", String.class, Integer.class);
Queue<String> queue = managerFactory.getQueue("queueList", String.class);
bucket.put("key", "value");
Optional<Value> value = bucket.get("key");
}
}
}