Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does redis configure files to connect to java clients

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to configure redis files and java client connections", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to configure the redis file and java client connection"!

Daemonize

Bind ip whitelist, 0.0.0.0.0 release all

Port 6379

Databases 0-15 16

Save persistence frequency

Ddbfilename persistent file name

Requirepass password requirepass 123456

Maximum number of simultaneous maxclient 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 / / cut library

Set username zs / / different libraries can store the same key

Set immoc:users:1 zs

Get immoc:users:1 / / hierarchical storage

Keys * / / all key

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 ();} @ Test public void testJedis () {Jedis j = JedisConnectionPool.getJedis (); j.select (2) String result = j.set ("user", "zs"); System.out.println ("result =" + result); String result2 = j.get ("user"); System.out.println ("result2 =" + result2); j.set ("level1:level2:1", "zs"); String level = j.get ("levle1:level2:1") System.out.println ("level =" + level); Set set = j.keys ("*"); System.out.println ("set =" + set);} at this point, I believe you have a better understanding of "how to configure redis files and java client connections". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report