set() Method
Creating a key and setting a value.
jedis.set(key,value)
Parameters: Key and Value can be given in bytes or string format.
Code Snippet :
Java
package org.w3wiki; import redis.clients.jedis.Jedis; public class Main { public static void main(String[] args) { Jedis jedis = new Jedis(); jedis.set("key", "value"); } } |
Redis cache in Java using Jedis
Jedis is the client library for Java in Redis that provides all the Redis features in applications based on Java. It is thread-safe and supports all the data types that Redis supports. It also provides the Jedis pooling which helps in creating a 3pool of connections that can be reused to enhance the performance.
Redis cache is a popularly used in-memory cache that acts like a data structure server that is used by many applications in use cases like caching, real-time analytics, and session management to make high-performance data access and storage. It also persist data periodically to the disk but RAM is the primary access.
Table of Content
- Download Redis based on the operating system and start the server:
- Basic operations performed on Jedis:
- 1. set() Method:
- 3. exists() method:
- 4. del() method :