Mac涓婄殑redis瀹夎涓巎edis鍏ラ棬

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mac涓婄殑redis瀹夎涓巎edis鍏ラ棬相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/https' title='https'>https   鍊掓暟   鏁版嵁缁撴瀯   str   int   server   浠g爜   reac   

Redis 鏄竴涓紑婧愶紙BSD璁稿彲锛夌殑锛屽唴瀛樹腑鐨勬暟鎹粨鏋勫瓨鍌ㄧ郴缁燂紝瀹冨彲浠ョ敤浣滄暟鎹簱銆佺紦瀛樺拰娑堟伅涓棿浠?/p>

瀹夎涓庨厤缃?/h2>

(1) https://redis.io/download涓嬭浇redis stable鏈€鏂扮増

灏嗗帇缂╁寘瑙e帇鍒颁綘鐨勬枃浠跺す涓?/p>

(2) 杩涘叆鍒皉edis鏂囦欢澶圭殑鏍圭洰褰?/p>

# 缂栬瘧娴嬭瘯(璺宠繃涔熷彲浠?
sudo make test
# 缂栬瘧瀹夎
sudo make install
# 瀹夎瀹屾垚浠ュ悗鍚姩
redis-server

鎶€鏈浘鐗? src=

(3) 绠€鍗曟祴璇?/p>

鏂板缓涓€涓猼erminal, 杈撳叆

redis-cli  # 瀹㈡埛绔?/pre>

瀛樹竴涓畝鍗曠殑kv

鎶€鏈浘鐗? src=

Jedis浣跨敤

Redis鍛戒护鍙傝€?nbsp;http://redisdoc.com/list/ltrim.html [鎺ㄨ崘, 寰堝叏]

(1) 杩炴帴鍒癹edis鏈嶅姟

涓嬭浇渚濊禆鐨刯ar鍖?nbsp;https://mvnrepository.com/artifact/redis.clients/jedis/2.9.0

鎴栬€呬娇鐢∕aven鏇存柟渚?/p>

<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency>
    <groupId>redis.clients</groupId>
    <artifactId>jedis</artifactId>
    <version>2.9.0</version>
</dependency>

鐒跺悗鍦ㄤ唬鐮佷腑杩炲埌jedis

public class JedisTest 
    public static void main(String args[]) 
        //杩炴帴鏈湴鐨?Redis 鏈嶅姟
        Jedis jedis = new Jedis("localhost");
        System.out.println("杩炴帴鎴愬姛");
        //鏌ョ湅鏈嶅姟鏄惁杩愯
        System.out.println("鏈嶅姟姝e湪杩愯: "+jedis.ping());
    

杈撳嚭
杩炴帴鎴愬姛
鏈嶅姟姝e湪杩愯: PONG

杩炴帴鎴愬姛浠ュ悗鍋氫竴浜涘熀鏈搷浣?/p>

(2) jedis鍩烘湰鎿嶄綔

涓€ jedis鏈€鍩烘湰鐨勬搷浣滃氨鏄痵et

鎶€鏈浘鐗? src=

jedis.set("yyq", "1995");
System.out.println(jedis.get("yyq"));

浜屻€乯edis杩樺彲浠ュ瓨list

"lpush"

// 浠庡乏杈瑰帇浜嗕袱涓? 浠庡彸杈瑰帇浜嗕竴涓? 鎵€浠ラ『搴忔槸1996, 1995, 1997
jedis.lpush("test", "1995"); jedis.lpush("test", "1996"); jedis.rpush("test","1997");
// -1琛ㄧず鏈€鍚庝竴涓? 杩欐牱鍙互鍏ㄦ嬁鍑烘潵 jedis.lrange(
"test", 0, -1).forEach(System.out::println);

涔熷彲浠ヨ浆鎴愬瓧鑺傛暟缁勫啀瀛? 杩欐牱鍙互鍖呭惈鏇村淇℃伅

"ltrim"

// 鍙繚鐣欎粠0鍒板€掓暟绗簩涓?澶村熬鍒颁細淇濈暀)
jedis.ltrim("test", 0, -2); jedis.lrange("test", 0, -1).forEach(System.out::println);
// 鍥犳杈撳嚭鍙墿 1996, 1995

"lindex"

鍙栧緱鎸囧畾index鐨勫厓绱?/p>

System.out.println(jedis.lindex("test", 0));  //杈撳嚭绗竴涓厓绱?996

 

以上是关于Mac涓婄殑redis瀹夎涓巎edis鍏ラ棬的主要内容,如果未能解决你的问题,请参考以下文章

鏈瓙涓婄殑灏忛€熷啓 | Sketch

webpack鍏ラ棬-涓汉瀛︿範璧勬簮鏀堕泦

Java鍏ラ棬(鍩虹绡囦竴)

鍊嶅鍏ラ棬

mybatis鍏ラ棬

JavaPoet鍏ラ棬