場景 Centos中Redis的下載編譯與安裝(超詳細): https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103967334 Redis的啟動和關閉(前臺啟動和後臺啟動): https://blog.csdn.net/BADAO_ ...
場景
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")); }