Anecdotes about Redis issues


foreword

Redis has Linux and Windows versions. Because the Java language is cross-platform, it is normally developed under windows (I am windows anyway). Because redis comes with a command line client, I usually open the directory where redis is located. , double-click the file to open, but many times it will flash by, which is very strange (although it is opened, but I have obsessive-compulsive disorder and feel uncomfortable), in short, it is outrageous that various such problems will appear. Write it down so you don't forget.


1. About Redis startup

In fact, Redis has already been opened, (emmmm can’t say 80% absolutely, you can open the taskbar to search redis-server)
insert image description here
if there is, it is opened
, but you don’t worry, it is recommended to use the following methods, first win + r to open Command line and then cmd
call out, enter the location where you downloaded redis, like mine is D drive redis,
then the command is
d:
cd redis
can enter the project, and then enter
redis-server
to start
insert image description here
and then command The line page will also pop up such a thing.
Of course, the default port of redis is 6379. If your port is occupied or you don’t want to use this port, you can use to redis-server --port 8888specify the port. Like I am referring to port 8888
emmm this is about redis startup part of

2. About the Redis database

Redis supports 16 databases by default. Each database is named with an increasing number starting from 0. Of course, if your machine is strong enough,
you can configure the value of databases through the redis.windows-service.conf file. There is no upper limit. After the client establishes a connection with Redis, the system will automatically select No. 0 database. You can use the select command to pick your favorite one.
For example, I want to choose No. 7.

select 7

3. Common commands about Redis

emmm, well, I usually don’t use a few of them, but it’s important to remember some

keys: query all keys
del key: delete key
exists key: determine whether a key exists
set key value: modify its value if a key exists, or create it if it does not exist
mset key1 value1 key2 value2: set multiple settings at a time value

If you encounter emmm, search for it by yourself, these five axes are enough, and you have two sets of skills more than Cheng Yaojin.


Four, spring boot operation Redis

A long time ago, there was a technology called jedis that was officially recommended by Redis for java, but that was a matter of spring boot1
. The problem of thread concurrent access, the former is not thread-safe in the case of multi-threading. It's a bit long-winded, let's get down to business, how to use it, like the idea I used, you only need to select it from NoSQL when creating the technical dependency, and you can configure emmm in application.yml Don't ask why yml has
it You can read my article if you want

#redis
spring:
 redis:
  host:127.0.0.1
  port:xxx #服务器连接端口
  database:1 #redis数据库索引(默认为0哦)
  pool:
   max-active:x #默认连接池最大数(可以用负数,用了就是代表没有限制)
   max-wait:x #连接池最大阻塞等待时间
   max-idle:x #连接池最大的空闲连接
   min-idle: x #连接池中最小的空闲连接
  timeout: 1000 #连接超时时间(毫秒是它的单位哦)   


Summarize

emmm, there are so many things in general, maybe I will add it when I encounter it in the future.
max-a

Guess you like

Origin blog.csdn.net/weixin_51759592/article/details/125764062