Home > Java > javaTutorial > body text

How to connect redis configuration file to java client

王林
Release: 2023-05-22 11:37:05
forward
1639 people have browsed it

daemonize

bind ip whitelist, 0.0.0.0.0 releases all

port 6379

databases 0-15 16

save persistent Frequency

ddbfilename Persistent file name

requirepass Password requirepass 123456

maxclient Maximum number of simultaneous connections

maxmemory Maximum memory


./redis-cli -h 193.168.0.1 -p 6379 -a 123456  // -h -p can be omitted

set username zs

get username

select 2 //Setting the library

set username zs //Different libraries can store the same key

set immoc:users:1 zs

get immoc:users:1   // Hierarchical storage

keys * //All keys

info

flushall //Clear all

package com.itheima.springbootradis.tools;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisConnectionPool {

    static Jedis j;
    static JedisPool pool;

    static {
        j = new Jedis("127.0.0.1", 6379);
        j.auth("123456");
        String pong = j.ping();
        System.out.println("pong = " + pong);

        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxTotal(5);
        jedisPoolConfig.setMaxIdle(6);

        pool = new JedisPool(jedisPoolConfig, "192.168.10.101", 6379, 100, "123456");
    }

    public static Jedis getJedis() {
        return pool.getResource();
    }

}
Copy after login
rrree

The above is the detailed content of How to connect redis configuration file to java client. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!