Redis对API和数据库的操作

博客介绍了Redis中默认的16个数据库及其索引,并讲解了如何切换数据库。同时,重点阐述了Redis API的使用步骤,包括通过Pom文件配置、获取Jedis连接池和连接对象,以及调用API进行操作。内容适合于企业实践中对Redis的操作。
摘要由CSDN通过智能技术生成

redis 默认16 个 数据库 ,0-15(索引)
redis 中数据库的切换
flushdb 把一个数据库的所有数据删除
flushall 清空所有的redis数据库(16个)


Redis API操作
1 pom文件

<dependencies>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <!--    <verbal>true</verbal>-->
                </configuration>
            </plugin>
        </plugins>
    </build>

redis api操作就三部(简单)
第一 获取redis 连接池
JedisPool jp=new JedisPool (“节点”,端口号)
第二 获取redis 连接对象
Jdeis jds =jp.getResource()
第三 通过对象调用API
jds.方法


企业用的
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值