首页  »   NoSQL

NoSQL-Redis鍩虹

网友分享于:2013-06-29  浏览:0次
NoSQL---Redis鍩虹

Redis(REmote DIctionary Server)鏄竴涓紑婧愮殑浣跨敤ANSI C璇█缂栧啓銆侀伒瀹圔SD鍗忚銆佹敮鎸佺綉缁溿€佸彲鍩轰簬鍐呭瓨浜﹀彲鎸佷箙鍖栫殑鏃ュ織鍨嬨€並ey-Value鏁版嵁搴撱€?/p>

Redis 鏄畬鍏ㄥ紑婧愬厤璐圭殑锛岄伒瀹圔SD鍗忚锛屾槸涓€涓珮鎬ц兘鐨刱ey-value鏁版嵁搴撱€?/p>

Redis 涓庡叾浠?key - value 缂撳瓨浜у搧鏈変互涓嬩笁涓壒鐐癸細

Redis 浼樺娍

Redis 鏁版嵁绫诲瀷

Redis鏀寔浜旂鏁版嵁绫诲瀷锛歴tring锛堝瓧绗︿覆锛夛紝hash锛堝搱甯岋級锛宭ist锛堝垪琛級锛宻et锛堥泦鍚堬級鍙妟set(sorted set锛氭湁搴忛泦鍚?銆?/p>

Redis keys 鍛戒护

keys * 聽:聽鏌ョ湅鎵€鏈夌殑key

keys "miao*"聽:聽鏌ョ湅鍖归厤鍓嶇紑鐨刱eys

flushdb聽:聽娓呯┖redis

type key聽:聽鏌ョ湅key鐨勭被鍨?/p>

dbsize聽:聽鏌ョ湅鏁版嵁搴撲腑key鐨勬暟閲?/p>

exists key : 鏌ョ湅鏄惁瀛樺湪璇ュ厓绱?/p>

del 聽key聽:聽鍒犻櫎鍏冪礌

expire key seconds锛氳缃鍏冪礌澶氬皯绉掑悗澶辨晥

ttl key:鏌ョ湅杩樺彲浠ュ瓨娲诲涔?-2琛ㄧずkey涓嶅瓨鍦?聽-1琛ㄧず瀹氭椂浠诲姟娑堝け锛屾案涔呭瓨鍌?/p>

Redis 瀛楃涓?String)

SET key value : 璁剧疆鎸囧畾 key 鐨勫€?鑻ュ瓨鍦ㄥ垯瑕嗙洊

GET key : 鑾峰彇鎸囧畾 key 鐨勫€笺€?/p>

MSET key value [key value ...] : 鍚屾椂璁剧疆涓€涓垨澶氫釜 key-value 瀵广€?/p>

MGET key1 [key2..] : 鑾峰彇鎵€鏈?涓€涓垨澶氫釜)缁欏畾 key 鐨勫€笺€?/p>

APPEND key value : 濡傛灉 key 宸茬粡瀛樺湪骞朵笖鏄竴涓瓧绗︿覆锛?APPEND 鍛戒护灏?value 杩藉姞鍒?key 鍘熸潵鐨勫€肩殑鏈熬

STRLEN key : 杩斿洖 key 鎵€鍌ㄥ瓨鐨勫瓧绗︿覆鍊肩殑闀垮害

redis鎻愪緵鍘熷瓙 鑷鎿嶄綔incr, 鐢ㄦ潵闃叉澶氱嚎绋嬪苟鍙戝嚭鐜版暟鎹敊璇紙涓€瀹氭槸鏁板€兼墠鑳借繘琛屽姞鍑忥級

incr key:鍘熷瓙鐨?1

decr key:鍘熷瓙鐨?1

incrby key integer:鍘熷瓙鐨?integer

decrby key integer:鍘熷瓙鐨?integer

Redis 鍝堝笇(Hash)

Redis hash 鏄竴涓猻tring绫诲瀷鐨刦ield鍜寁alue鐨勬槧灏勮〃锛宧ash鐗瑰埆閫傚悎鐢ㄤ簬瀛樺偍瀵硅薄銆?/p>

HSET key field value : 灏嗗搱甯岃〃 key 涓殑瀛楁 field 鐨勫€艰涓?value聽

HGET key field 聽: 鑾峰彇瀛樺偍鍦ㄥ搱甯岃〃涓寚瀹氬瓧娈电殑鍊?/p>

HMGET key field1 [field2] 聽: 聽鑾峰彇鎵€鏈夌粰瀹氬瓧娈电殑鍊?/p>

HMSET key field1 value1 [field2 value2 ] 聽: 聽鍚屾椂灏嗗涓?field-value (鍩?鍊?瀵硅缃埌鍝堝笇琛?key 涓€?/p>

HEXISTS key field : 鏌ョ湅鍝堝笇琛?key 涓紝鎸囧畾鐨勫瓧娈垫槸鍚﹀瓨鍦ㄣ€?/p>

HDEL key field2 [field2] : 鍒犻櫎涓€涓垨澶氫釜鍝堝笇琛ㄥ瓧娈?/p>

HGETALL key 聽鑾峰彇鍦ㄥ搱甯岃〃涓寚瀹?key 鐨勬墍鏈夊瓧娈靛拰鍊?/p>

HKEYS key : 鑾峰彇鎵€鏈夊搱甯岃〃涓殑瀛楁

HVALS key : 鑾峰彇鍝堝笇琛ㄤ腑鎵€鏈夊€?/p>

相关解决方案

最新解决方案