您好,登錄后才能下訂單哦!
這篇文章主要講解了“Client.java的源碼是什么”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Client.java的源碼是什么”吧!
基本都是發文件,通過調用sendcommand函數,這個函數在connection類內。
package redis.clients.jedis; import java.util.ArrayList; import java.util.List; import java.util.Map; public class Client extends Connection { private boolean isInMulti; //標志是否多命令執行狀態 public boolean isInMulti() {//返回命令狀態 return isInMulti; } public Client(String host) {//初始化父類connection super(host); } public Client(String host, int port) {//用ip/端口初始化父類 super(host, port); } public void ping() {//發送PING命令 sendCommand("PING"); } public void set(String key, String value) {//發送set命令 sendCommand("SET", key, value); } public void get(String key) {//發送get命令 sendCommand("GET", key); } public void quit() {//發送quit命令 sendCommand("QUIT"); } public void exists(String key) {//發送exists命令 sendCommand("EXISTS", key); } public void del(String... keys) {//發送del命令 sendCommand("DEL", keys); } public void type(String key) {//發送type命令 sendCommand("TYPE", key); } public void flushDB() {//發送flushdb命令 sendCommand("FLUSHDB"); } public void keys(String pattern) {//發送keys命令 sendCommand("KEYS", pattern); } public void randomKey() {//發送randomkey命令 sendCommand("RANDOMKEY"); } public void rename(String oldkey, String newkey) {//發送rename命令 sendCommand("RENAME", oldkey, newkey); } public void renamenx(String oldkey, String newkey) {//發送renamenx命令 sendCommand("RENAMENX", oldkey, newkey); } public void dbSize() {//發送dbsize命令 sendCommand("DBSIZE"); } public void expire(String key, int seconds) {//發送expire命令 sendCommand("EXPIRE", key, String.valueOf(seconds)); } public void expireAt(String key, long unixTime) {//發送expireat命令 sendCommand("EXPIREAT", key, String.valueOf(unixTime)); } public void ttl(String key) {//發送ttl命令 sendCommand("TTL", key); } public void select(int index) {//發送select命令 sendCommand("SELECT", String.valueOf(index)); } public void move(String key, int dbIndex) {//發送move命令 sendCommand("MOVE", key, String.valueOf(dbIndex)); } public void flushAll() {//發送flushall命令 sendCommand("FLUSHALL"); } public void getSet(String key, String value) {//發送getset命令 sendCommand("GETSET", key, value); } public void mget(String... keys) {//發送mget命令 sendCommand("MGET", keys); } public void setnx(String key, String value) {//發送命令setnx sendCommand("SETNX", key, value); } public void setex(String key, int seconds, String value) {//發送命令setex sendCommand("SETEX", key, String.valueOf(seconds), value); } public void mset(String... keysvalues) {//發送命令mset sendCommand("MSET", keysvalues); } public void msetnx(String... keysvalues) {//發送命令msetnx sendCommand("MSETNX", keysvalues); } public void decrBy(String key, int integer) {//發送命令decrby sendCommand("DECRBY", key, String.valueOf(integer)); } public void decr(String key) {//發送命令decr sendCommand("DECR", key); } public void incrBy(String key, int integer) {//發送命令incrby sendCommand("INCRBY", key, String.valueOf(integer)); } public void incr(String key) {//發送命令incr sendCommand("INCR", key); } public void append(String key, String value) {//發送命令append sendCommand("APPEND", key, value); } public void substr(String key, int start, int end) {//發送命令substr sendCommand("SUBSTR", key, String.valueOf(start), String.valueOf(end)); } public void hset(String key, String field, String value) {//發送命令hset sendCommand("HSET", key, field, value); } public void hget(String key, String field) {//發送命令hget sendCommand("HGET", key, field); } public void hsetnx(String key, String field, String value) {//發送命令hsetnx sendCommand("HSETNX", key, field, value); } public void hmset(String key, Map<String, String> hash) {//發送命令hmset List<String> params = new ArrayList<String>(); params.add(key); for (String field : hash.keySet()) { params.add(field); params.add(hash.get(field)); } sendCommand("HMSET", params.toArray(new String[params.size()])); } public void hmget(String key, String... fields) {//發送命令hmget String[] params = new String[fields.length + 1]; params[0] = key; System.arraycopy(fields, 0, params, 1, fields.length); sendCommand("HMGET", params); } public void hincrBy(String key, String field, int value) {//發送命令hincrby sendCommand("HINCRBY", key, field, String.valueOf(value)); } public void hexists(String key, String field) {//發送命令hexists sendCommand("HEXISTS", key, field); } public void hdel(String key, String field) {//發送命令hdel sendCommand("HDEL", key, field); } public void hlen(String key) {//發送命令hlen sendCommand("HLEN", key); } public void hkeys(String key) {//發送命令hkeys sendCommand("HKEYS", key); } public void hvals(String key) {//發送命令hvals sendCommand("HVALS", key); } public void hgetAll(String key) {//發送命令hgetall sendCommand("HGETALL", key); } public void rpush(String key, String string) {//發送命令rpush sendCommand("RPUSH", key, string); } public void lpush(String key, String string) {//發送命令lpush sendCommand("LPUSH", key, string); } public void llen(String key) {//發送命令llen sendCommand("LLEN", key); } public void lrange(String key, int start, int end) {//發送命令lrange sendCommand("LRANGE", key, String.valueOf(start), String.valueOf(end)); } public void ltrim(String key, int start, int end) {//發送命令ltrim sendCommand("LTRIM", key, String.valueOf(start), String.valueOf(end)); } public void lindex(String key, int index) {//發送命令lindex sendCommand("LINDEX", key, String.valueOf(index)); } public void lset(String key, int index, String value) {//發送命令lset sendCommand("LSET", key, String.valueOf(index), value); } public void lrem(String key, int count, String value) {//發送命令lrem sendCommand("LREM", key, String.valueOf(count), value); } public void lpop(String key) {//發送命令lpop sendCommand("LPOP", key); } public void rpop(String key) {//發送命令rpop sendCommand("RPOP", key); } public void rpoplpush(String srckey, String dstkey) {//發送命令rpoplpush sendCommand("RPOPLPUSH", srckey, dstkey); } public void sadd(String key, String member) {//發送命令sadd sendCommand("SADD", key, member); } public void smembers(String key) {//發送命令smembers sendCommand("SMEMBERS", key); } public void srem(String key, String member) {//發送命令srem sendCommand("SREM", key, member); } public void spop(String key) {//發送命令spop sendCommand("SPOP", key); } public void smove(String srckey, String dstkey, String member) {//發送命令smove sendCommand("SMOVE", srckey, dstkey, member); } public void scard(String key) {//發送命令scard sendCommand("SCARD", key); } public void sismember(String key, String member) {//發送命令sismember sendCommand("SISMEMBER", key, member); } public void sinter(String... keys) {//發送命令sinter sendCommand("SINTER", keys); } public void sinterstore(String dstkey, String... keys) {//發送命令sinterstore String[] params = new String[keys.length + 1]; params[0] = dstkey; System.arraycopy(keys, 0, params, 1, keys.length); sendCommand("SINTERSTORE", params); } public void sunion(String... keys) {//發送命令sunion sendCommand("SUNION", keys); } public void sunionstore(String dstkey, String... keys) {//發送命令sunionstore String[] params = new String[keys.length + 1]; params[0] = dstkey; System.arraycopy(keys, 0, params, 1, keys.length); sendCommand("SUNIONSTORE", params); } public void sdiff(String... keys) {//發送命令sdiff sendCommand("SDIFF", keys); } public void sdiffstore(String dstkey, String... keys) {//發送命令sdiffstore String[] params = new String[keys.length + 1]; params[0] = dstkey; System.arraycopy(keys, 0, params, 1, keys.length); sendCommand("SDIFFSTORE", params); } public void srandmember(String key) {//發送命令srandmember sendCommand("SRANDMEMBER", key); } public void zadd(String key, double score, String member) {//發送命令zadd sendCommand("ZADD", key, String.valueOf(score), member); } public void zrange(String key, int start, int end) {//發送命令zrange sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end)); } public void zrem(String key, String member) {//發送命令zrem sendCommand("ZREM", key, member); } public void zincrby(String key, double score, String member) {//發送命令zincrby sendCommand("ZINCRBY", key, String.valueOf(score), member); } public void zrank(String key, String member) {//發送命令zrank sendCommand("ZRANK", key, member); } public void zrevrank(String key, String member) {//發送命令zrevrank sendCommand("ZREVRANK", key, member); } public void zrevrange(String key, int start, int end) {//發送命令zrevrange sendCommand("ZREVRANGE", key, String.valueOf(start), String .valueOf(end)); } public void zrangeWithScores(String key, int start, int end) {//發送命令zrange sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end), "WITHSCORES"); } public void zrevrangeWithScores(String key, int start, int end) {//發送命令zrevrange sendCommand("ZREVRANGE", key, String.valueOf(start), String .valueOf(end), "WITHSCORES"); } public void zcard(String key) {//發送命令zcard sendCommand("ZCARD", key); } public void zscore(String key, String member) {//發送命令zscore sendCommand("ZSCORE", key, member); } public void multi() {//發送命令multi sendCommand("MULTI"); isInMulti = true; } public void discard() {//發送命令discard sendCommand("DISCARD"); isInMulti = false; } public void exec() {//發送命令exec sendCommand("EXEC"); isInMulti = false; } public void watch(String key) {//發送命令watch sendCommand("WATCH", key); } public void unwatch() {//發送命令unwatch sendCommand("UNWATCH"); } public void sort(String key) {//發送命令sort sendCommand("SORT", key); } public void sort(String key, SortingParams sortingParameters) {//發送命令sort List<String> args = new ArrayList<String>(); args.add(key); args.addAll(sortingParameters.getParams()); sendCommand("SORT", args.toArray(new String[args.size()])); } public void blpop(String[] args) {//發送命令blpop sendCommand("BLPOP", args); } public void sort(String key, SortingParams sortingParameters, String dstkey) {//發送命令sort List<String> args = new ArrayList<String>(); args.add(key); args.addAll(sortingParameters.getParams()); args.add("STORE"); args.add(dstkey); sendCommand("SORT", args.toArray(new String[args.size()])); } public void sort(String key, String dstkey) {//發送命令sort,store sendCommand("SORT", key, "STORE", dstkey); } public void brpop(String[] args) {//發送命令brpop sendCommand("BRPOP", args); } public void auth(String password) {//發送命令auth sendCommand("AUTH", password); } public void subscribe(String... channels) {//發送命令subscribe sendCommand("SUBSCRIBE", channels); } public void publish(String channel, String message) {//發送命令publish sendCommand("PUBLISH", channel, message); } public void unsubscribe() {//發送命令unsubscribe sendCommand("UNSUBSCRIBE"); } public void unsubscribe(String... channels) {//發送命令unsubscribe sendCommand("UNSUBSCRIBE", channels); } public void psubscribe(String[] patterns) {//發送命令psubscribe sendCommand("PSUBSCRIBE", patterns); } public void punsubscribe() {//發送命令punsubscribe sendCommand("PUNSUBSCRIBE"); } public void punsubscribe(String... patterns) {//發送命令punsubscribe sendCommand("PUNSUBSCRIBE", patterns); } public void zcount(String key, double min, double max) {//發送命令zcount sendCommand("ZCOUNT", key, String.valueOf(min), String.valueOf(max)); } public void zrangeByScore(String key, double min, double max) {//發送命令zrangebyscore sendCommand("ZRANGEBYSCORE", key, String.valueOf(min), String .valueOf(max)); } public void zrangeByScore(String key, double min, double max, int offset, int count) {//發送命令zrangebyscore sendCommand("ZRANGEBYSCORE", key, String.valueOf(min), String .valueOf(max), "LIMIT", String.valueOf(offset), String .valueOf(count)); } public void zrangeByScoreWithScores(String key, double min, double max) {//發送命令zrangebyscore sendCommand("ZRANGEBYSCORE", key, String.valueOf(min), String .valueOf(max), "WITHSCORES"); } public void zrangeByScoreWithScores(String key, double min, double max, int offset, int count) {//發送命令zrangebyscore sendCommand("ZRANGEBYSCORE", key, String.valueOf(min), String .valueOf(max), "LIMIT", String.valueOf(offset), String .valueOf(count), "WITHSCORES"); } public void zremrangeByRank(String key, int start, int end) {//發送命令zremrangebyrank sendCommand("ZREMRANGEBYRANK", key, String.valueOf(start), String .valueOf(end)); } public void zremrangeByScore(String key, double start, double end) {//發送命令zremrangebyscore sendCommand("ZREMRANGEBYSCORE", key, String.valueOf(start), String .valueOf(end)); } public void zunionstore(String dstkey, String... sets) {//發送命令zunionstore String[] params = new String[sets.length + 2]; params[0] = dstkey; params[1] = String.valueOf(sets.length); System.arraycopy(sets, 0, params, 2, sets.length); sendCommand("ZUNIONSTORE", params); } public void zunionstore(String dstkey, ZParams params, String... sets) {//發送命令zunionstore List<String> args = new ArrayList<String>(); args.add(dstkey); args.add(String.valueOf(sets.length)); for (String set : sets) { args.add(set); } args.addAll(params.getParams()); sendCommand("ZUNIONSTORE", args.toArray(new String[args.size()])); } public void zinterstore(String dstkey, String... sets) {//發送命令zinterstore String[] params = new String[sets.length + 2]; params[0] = dstkey; params[1] = String.valueOf(sets.length); System.arraycopy(sets, 0, params, 2, sets.length); sendCommand("ZINTERSTORE", params); } public void zinterstore(String dstkey, ZParams params, String... sets) {//發送命令zinterstore List<String> args = new ArrayList<String>(); args.add(dstkey); args.add(String.valueOf(sets.length)); for (String set : sets) { args.add(set); } args.addAll(params.getParams()); sendCommand("ZINTERSTORE", args.toArray(new String[args.size()])); } public void save() {//發送命令save sendCommand("SAVE"); } public void bgsave() {//發送命令bgsave sendCommand("BGSAVE"); } public void bgrewriteaof() {//發送命令bgrewriteaof sendCommand("BGREWRITEAOF"); } public void lastsave() {//發送命令lastsave sendCommand("LASTSAVE"); } public void shutdown() {//發送命令shutdown sendCommand("SHUTDOWN"); } public void info() {//發送命令info sendCommand("INFO"); } public void monitor() {//發送命令monitor sendCommand("MONITOR"); } public void slaveof(String host, int port) {//發送命令slaveof sendCommand("SLAVEOF", host, String.valueOf(port)); } public void slaveofNoOne() {//發送命令slaveof sendCommand("SLAVEOF", "no", "one"); } public void configGet(String pattern) {//發送命令config get sendCommand("CONFIG", "GET", pattern); } public void configSet(String parameter, String value) {//發送命令config set sendCommand("CONFIG", "SET", parameter, value); } }
感謝各位的閱讀,以上就是“Client.java的源碼是什么”的內容了,經過本文的學習后,相信大家對Client.java的源碼是什么這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。