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 :

Similar Reads

Download Redis based on the operating system and start the server:

In Windows, it gets started by running redis-server.exe, and in Linux/OS run the command redis-server to start the Redis server. Importing Import Jedis into application by adding Maven Dependency in pom.xml:...

Basic operations performed on Jedis:

1. set() Method:...

1. set() Method:

Creating a key and setting a value....

2. get() method:

...

3. exists() method:

Reading a value of a key,...

4. del() method :

...