Centos中Redis的下载编译与安装(超详细):
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103967334
Redis的启动和关闭(前台启动和后台启动):
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103972348
RedisDesktopManager客户端可视化工具下载安装与使用:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103983147
Java中使用Jedis连接Redis对Key进行操作的常用命令:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/104915569
参考上面对Key进行操作的命令后,下面是对String进行常用操作。
注:
博客:
https://blog.csdn.net/badao_liumang_qizhi关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
新建Junit方法TestString,然后依次打开以下注释代码
@Test public void TestString() { //System.out.println("增加数据key1-value1"+jedis.set("key1","value1")); //System.out.println("增加数据key2-value2"+jedis.set("key2","value2")); //System.out.println("增加数据key3-value3" + jedis.set("key3", "value3")); //System.out.println("删除数据key3"+jedis.del("key3")); //System.out.println("获取数据key2"+jedis.get("key2")); //System.out.println("在key2后面追加值"+jedis.append("key2","append")); //System.out.println("在key2后面追加值"+jedis.append("key2","append")); //System.out.println("增加多个键值:" + jedis.mset("key01", "value01", "key02", "value02", "key03", "value03")); //System.out.println("获取多个键值:" + jedis.mget("key01", "key02", "key03")); //System.out.println("删除多个键值:"+jedis.del("key02","key03")); //新增键值对防止覆盖原先值 //输出1 //System.out.println(jedis.setnx("key4","badao")); //输出0 //System.out.println(jedis.setnx("key4","liumang")); //输出badao //System.out.println(jedis.get("key4")); //新增键值对并设置有效时间--5秒 //System.out.println(jedis.setex("key5",5,"liumang")); //获取原值并更新为新值 System.out.println(jedis.getSet("key4","key4getset")); System.out.println(jedis.get("key4")); }