package redis.clients.jedis;
import static redis.clients.jedis.Protocol.toByteArray;
import java.io.Closeable;
import java.net.URI;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.commands.*;
import redis.clients.jedis.exceptions.InvalidURIException;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.jedis.params.geo.GeoRadiusParam;
import redis.clients.jedis.params.set.SetParams;
import redis.clients.jedis.params.sortedset.ZAddParams;
import redis.clients.jedis.params.sortedset.ZIncrByParams;
import redis.clients.util.JedisByteHashMap;
import redis.clients.util.JedisURIHelper;
import redis.clients.util.SafeEncoder;
public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKeyBinaryCommands,
AdvancedBinaryJedisCommands, BinaryScriptingCommands, Closeable {
protected Client client = null;
protected Transaction transaction = null;
protected Pipeline pipeline = null;
public BinaryJedis() {
client = new Client();
}
public BinaryJedis(final String host) {
URI uri = URI.create(host);
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
initializeClientFromURI(uri);
} else {
client = new Client(host);
}
}
public BinaryJedis(final String host, final int port) {
client = new Client(host, port);
}
public BinaryJedis(final String host, final int port, final int timeout) {
client = new Client(host, port);
client.setConnectionTimeout(timeout);
client.setSoTimeout(timeout);
}
public BinaryJedis(final String host, final int port, final int connectionTimeout,
final int soTimeout) {
client = new Client(host, port);
client.setConnectionTimeout(connectionTimeout);
client.setSoTimeout(soTimeout);
}
public BinaryJedis(final JedisShardInfo shardInfo) {
client = new Client(shardInfo.getHost(), shardInfo.getPort());
client.setConnectionTimeout(shardInfo.getConnectionTimeout());
client.setSoTimeout(shardInfo.getSoTimeout());
client.setPassword(shardInfo.getPassword());
client.setDb(shardInfo.getDb());
}
public BinaryJedis(URI uri) {
initializeClientFromURI(uri);
}
public BinaryJedis(final URI uri, final int timeout) {
initializeClientFromURI(uri);
client.setConnectionTimeout(timeout);
client.setSoTimeout(timeout);
}
public BinaryJedis(final URI uri, final int connectionTimeout, final int soTimeout) {
initializeClientFromURI(uri);
client.setConnectionTimeout(connectionTimeout);
client.setSoTimeout(soTimeout);
}
private void initializeClientFromURI(URI uri) {
if (!JedisURIHelper.isValid(uri)) {
throw new InvalidURIException(String.format(
"Cannot open Redis connection due invalid URI. %s", uri.toString()));
}
client = new Client(uri.getHost(), uri.getPort());
String password = JedisURIHelper.getPassword(uri);
if (password != null) {
client.auth(password);
client.getStatusCodeReply();
}
int dbIndex = JedisURIHelper.getDBIndex(uri);
if (dbIndex > 0) {
client.select(dbIndex);
client.getStatusCodeReply();
client.setDb(dbIndex);
}
}
@Override
public String ping() {
checkIsInMultiOrPipeline();
client.ping();
return client.getStatusCodeReply();
}
/**
* Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1
* GB).
* <p>
* Time complexity: O(1)
* @param key
* @param value
* @return Status code reply
*/
@Override
public String set(final byte[] key, final byte[] value) {
checkIsInMultiOrPipeline();
client.set(key, value);
return client.getStatusCodeReply();
}
/**
* Set the string value as value of the key. The string can't be longer than 1073741824 bytes (1
* GB).
* @param key
* @param value
* @param params
* @return Status code reply
*/
@Override
public String set(final byte[] key, final byte[] value, final SetParams params) {
checkIsInMultiOrPipeline();
client.set(key, value, params);
return client.getStatusCodeReply();
}
/**
* Get the value of the specified key. If the key does not exist the special value 'nil' is
* returned. If the value stored at key is not a string an error is returned because GET can only
* handle string values.
* <p>
* Time complexity: O(1)
* @param key
* @return Bulk reply
*/
@Override
public byte[] get(final byte[] key) {
checkIsInMultiOrPipeline();
client.get(key);
return client.getBinaryBulkReply();
}
/**
* Ask the server to silently close the connection.
*/
@Override
public String quit() {
checkIsInMultiOrPipeline();
client.quit();
String quitReturn = client.getStatusCodeReply();
client.disconnect();
return quitReturn;
}
/**
* Test if the specified keys exist. The command returns the number of keys existed Time
* complexity: O(N)
* @param keys
* @return Integer reply, specifically: an integer greater than 0 if one or more keys existed 0 if
* none of the specified keys existed
*/
@Override
public Long exists(final byte[]... keys) {
checkIsInMultiOrPipeline();
client.exists(keys);
return client.getIntegerReply();
}
/**
* Test if the specified key exists. The command returns "1" if the key exists, otherwise "0" is
* returned. Note that even keys set with an empty string as value will return "1". Time
* complexity: O(1)
* @param key
* @return Boolean reply, true if the key exists, otherwise false
*/
@Override
public Boolean exists(final byte[] key) {
checkIsInMultiOrPipeline();
client.exists(key);
return client.getIntegerReply() == 1;
}
/**
* Remove the specified keys. If a given key does not exist no operation is performed for this
* key. The command returns the number of keys removed. Time complexity: O(1)
* @param keys
* @return Integer reply, specifically: an integer greater than 0 if one or more keys were removed
* 0 if none of the specified key existed
*/
@Override
public Long del(final byte[]... keys) {
checkIsInMultiOrPipeline();
client.del(keys);
return client.getIntegerReply();
}
@Override
public Long del(final byte[] key) {
checkIsInMultiOrPipeline();
client.del(key);
return client.getIntegerReply();
}
/**
* Return the type of the value stored at key in form of a string. The type can be one of "none",
* "string", "list", "set". "none" is returned if the key does not exist. Time complexity: O(1)
* @param key
* @return Status code reply, specifically: "none" if the key does not exist "string" if the key
* contains a String value "list" if the key contains a List value "set" if the key
* contains a Set value "zset" if the key contains a Sorted Set value "hash" if the key
* contains a Hash value
*/
@Override
public String type(final byte[] key) {
checkIsInMultiOrPipeline();
client.type(key);
return client.getStatusCodeReply();
}
/**
* Delete all the keys of the currently selected DB. This command never fails.
* @return Status code reply
*/
@Override
public String flushDB() {
checkIsInMultiOrPipeline();
client.flushDB();
return client.getStatusCodeReply();
}
/**
* Returns all the keys matching the glob-style pattern as space separated strings. For example if
* you have in the database the keys "foo" and "foobar" the command "KEYS foo*" will return
* "foo foobar".
* <p>
* Note that while the time comple
没有合适的资源?快使用搜索试试~ 我知道了~
基于SpringBoot+SpringCloud+Mybatis+Docker分布式敏捷开发系统架构,提供整套公共微.zip
共1603个文件
java:913个
js:162个
xml:122个
需积分: 5 0 下载量 49 浏览量
2024-02-04
16:36:37
上传
评论
收藏 4.8MB ZIP 举报
温馨提示
基于SpringBoot+SpringCloud+Mybatis+Docker分布式敏捷开发系统架构,提供整套公共微
资源推荐
资源详情
资源评论
收起资源包目录
基于SpringBoot+SpringCloud+Mybatis+Docker分布式敏捷开发系统架构,提供整套公共微.zip (1603个子文件)
cachecloud-web.conf 969B
bootstrap.css 123KB
bootstrap.css 120KB
bootstrap.min.css 100KB
bootstrap.min.css 97KB
style.css 76KB
animate.css 60KB
style-metronic.css 25KB
font-awesome.css 22KB
style.css 21KB
docs.min.css 21KB
plugins.css 20KB
font-awesome.min.css 18KB
bootstrap-theme.css 14KB
bootstrap-theme.min.css 13KB
light.css 10KB
style-responsive.css 9KB
purple.css 8KB
blue.css 8KB
brown.css 8KB
grey.css 8KB
default.css 8KB
inbox.css 8KB
pricing-tables.css 6KB
timeline.css 6KB
theme.css 5KB
profile.css 5KB
style-non-responsive.css 4KB
datepicker.css 4KB
DT_bootstrap.css 3KB
datepicker.css 3KB
login.css 3KB
login-soft.css 3KB
blog.css 2KB
search.css 2KB
error.css 2KB
news.css 2KB
lock.css 2KB
portfolio.css 2KB
mem-cloud.css 2KB
invalid.css 2KB
coming-soon.css 2KB
tasks.css 2KB
prettify.css 2KB
login.css 1KB
promo.css 1KB
reset.css 1KB
image-crop.css 945B
font.css 879B
email.css 706B
invoice.css 528B
print.css 328B
about-us.css 267B
WdatePicker.css 149B
custom.css 71B
Dockerfile 190B
Dockerfile 187B
Dockerfile 187B
Dockerfile 186B
Dockerfile 186B
Dockerfile 180B
Dockerfile 179B
Dockerfile 179B
fontawesome-webfont.eot 37KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
bg-sidebar.gif 32KB
ajax-loading.gif 29KB
ajax-modal-loading.gif 27KB
bg-body.gif 21KB
bg-radial-gradient.gif 17KB
bg-login.gif 13KB
levels.gif 5KB
bg-menu-item-green.gif 3KB
loading.gif 3KB
input-spinner.gif 2KB
img.gif 2KB
icons.gif 2KB
img.gif 2KB
loading.gif 2KB
shortcut-button-bg.gif 1KB
today-bg.gif 1KB
datePicker.gif 1KB
tips_icon.gif 796B
bg-menu-item-current.gif 315B
bg-button-green.gif 169B
bg-content-box.gif 126B
title-bg.gif 116B
status-bg.gif 116B
normal-bg.gif 110B
rowhover-bg.gif 110B
bg-form-field.gif 97B
active-bg.gif 89B
hover-bg.gif 89B
dark-bg.gif 85B
menu-current-arrow.gif 59B
menuarrow.gif 49B
pv.gif 0B
.gitignore 609B
My97DatePicker.htm 1KB
共 1603 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
码农阿豪
- 粉丝: 1w+
- 资源: 1754
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功