Java Code Examples for redis.clients.jedis.Jedis.hmset()
来源:互联网 发布:重庆博拉网络 编辑:程序博客网 时间:2024/05/19 03:20
Java Code Examples for redis.clients.jedis.Jedis.hmset()
The following are Jave code examples for showing how to usehmset()of theredis.clients.jedis.Jedis class.You can vote up the examples you like. Your votes will be used in our system to getmore good examples.
+ Save this method
Example 1
Project: dk-masterView Source6votes
/** * ?????hash???????byte???? * @param mapKey * @param data */public void putToMap(byte[] mapKey, Map<byte[], byte[]> data) {Jedis conn = getConnection();if (conn == null) {return;}try {conn.hmset(mapKey, data);returnConnection(conn);} catch (Exception e) {returnBorkenConnection(conn);}}
Example 2
Project: TOTP-authentication-demo-masterView Source6votes
@Overridepublic void addAccount(Account account) {Jedis jedis = null;try {jedis = pool.getResource();long id = getIncresedId();Map<String, String> hash = new HashMap<String, String>();hash.put("name", account.getName());hash.put("password", account.getPassword());hash.put("secret", account.getSecret());hash.put("created", Long.toString(account.getCreated().getTime()));jedis.set(getAccountNameIndexKey(account.getName()), Long.toString(id));jedis.hmset(getAccountDataKey(Long.toString(id)), hash);} finally {pool.returnResource(jedis);}}
Example 3
Project: jfinal-masterView Source6votes
/** * ????? field-value (?-?)??????? key ?? * ???????????????? * ?? key ???????????????? HMSET ??? */public String hmset(Object key, Map<Object, Object> hash) {Jedis jedis = getJedis();try {Map<byte[], byte[]> para = new HashMap<byte[], byte[]>();for (Entry<Object, Object> e : hash.entrySet())para.put(keyToBytes(e.getKey()), valueToBytes(e.getValue()));return jedis.hmset(keyToBytes(key), para);}finally {close(jedis);}}
Example 4
Project: redis-store-masterView Source6votes
public void save(Session session) throws IOException { ObjectOutputStream oos = null; ByteArrayOutputStream bos = null; Map<byte[], byte[]> hash = new HashMap<byte[], byte[]>(); bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(new BufferedOutputStream(bos)); ((StandardSession) session).writeObjectData(oos); oos.close(); oos = null; hash.put(ID_FIELD, session.getIdInternal().getBytes()); hash.put(DATA_FIELD, bos.toByteArray()); Jedis jedis = getJedis(); jedis.hmset(session.getIdInternal().getBytes(), hash); closeJedis(jedis); if (log.isLoggable(Level.INFO)) { log.info("Saved session with id " + session.getIdInternal()); }}
Example 5
Project: redis-quartz-masterView Source6votes
/** * Stores job in redis. * * @param newJob the new job * @param replaceExisting the replace existing * @param jedis thread-safe redis connection * @throws ObjectAlreadyExistsException */private void storeJob(JobDetail newJob, boolean replaceExisting, Jedis jedis)throws ObjectAlreadyExistsException {String jobHashKey = createJobHashKey(newJob.getKey().getGroup(), newJob.getKey().getName());String jobDataMapHashKey = createJobDataMapHashKey(newJob.getKey().getGroup(), newJob.getKey().getName());String jobGroupSetKey = createJobGroupSetKey(newJob.getKey().getGroup());if (jedis.exists(jobHashKey) && !replaceExisting)throw new ObjectAlreadyExistsException(newJob);Map<String, String> jobDetails = new HashMap<String, String>();jobDetails.put(DESCRIPTION, newJob.getDescription() != null ? newJob.getDescription() : "");jobDetails.put(JOB_CLASS, newJob.getJobClass().getName());jobDetails.put(IS_DURABLE, Boolean.toString(newJob.isDurable()));jobDetails.put(BLOCKED_BY, "");jobDetails.put(BLOCK_TIME, "");jedis.hmset(jobHashKey, jobDetails);if (newJob.getJobDataMap() != null && !newJob.getJobDataMap().isEmpty())jedis.hmset(jobDataMapHashKey, getStringDataMap(newJob.getJobDataMap()));jedis.sadd(JOBS_SET, jobHashKey);jedis.sadd(JOB_GROUPS_SET, jobGroupSetKey);jedis.sadd(jobGroupSetKey, jobHashKey);}
Example 6
Project: OG-Platform-masterView Source6votes
protected void updateTimeSeries(String redisKey, LocalDateDoubleTimeSeries timeseries, boolean clear, int attempts) { try (Timer.Context context = _updateSeriesTimer.time()) { Jedis jedis = getJedisPool().getResource(); try { Map<String, String> htsMap = Maps.newHashMap(); BiMap<Double, String> dates = HashBiMap.create(); for (Entry<LocalDate, Double> entry : timeseries) { String dateAsIntText = Integer.toString(LocalDateToIntConverter.convertToInt(entry.getKey())); htsMap.put(dateAsIntText, Double.toString(entry.getValue())); dates.put(Double.valueOf(dateAsIntText), dateAsIntText); } String redisHtsDatapointKey = toRedisHtsDatapointKey(redisKey); jedis.hmset(redisHtsDatapointKey, htsMap); String redisHtsDaysKey = toRedisHtsDaysKey(redisKey); if (clear) { jedis.del(redisHtsDaysKey); } else { jedis.zrem(redisHtsDaysKey, dates.inverse().keySet().toArray(new String[dates.size()])); } jedis.zadd(redisHtsDaysKey, dates); getJedisPool().returnResource(jedis); } catch (Throwable e) { getJedisPool().returnBrokenResource(jedis); if (attempts > 0) { s_logger.warn("Unable to put timeseries with id, will retry: " + redisKey, e); updateTimeSeries(redisKey, timeseries, clear, attempts - 1); } throw new OpenGammaRuntimeException("Unable to put timeseries with id: " + redisKey, e); } }}
Example 7
Project: trident-extended-state-masterView Source6votes
@Overridepublic void multiPut(Map<K, V> values) {Jedis jedis = this.pool.getResource();try {byte[] rawKey = this.generateKey();Map<byte[], byte[]> rawHash = new HashMap<byte[], byte[]>(values.size());for (Entry<K, V> entry : values.entrySet()) {rawHash.put(keySerializer.serialize(entry.getKey()), serializer.serialize(entry.getValue()));}jedis.hmset(rawKey, rawHash);} finally {this.pool.returnResource(jedis);}}
Example 8
Project: Carolina-Digital-Repository-masterView Source6votes
public void started(String jobUUID, String depositUUID, Class<?> jobClass) {Map<String, String> status = new HashMap<String, String>();status.put(JobField.uuid.name(), jobUUID);status.put(JobField.name.name(), jobClass.getName());status.put(JobField.status.name(), JobStatus.working.name());status.put(JobField.starttime.name(),String.valueOf(System.currentTimeMillis()));status.put(JobField.num.name(), "0");Jedis jedis = getJedisPool().getResource();jedis.hmset(JOB_STATUS_PREFIX + jobUUID, status);jedis.rpush(DEPOSIT_TO_JOBS_PREFIX + depositUUID, jobUUID);getJedisPool().returnResource(jedis);}
来自: http://www.programcreek.com/java-api-examples/index.php?class=redis.clients.jedis.Jedis&method=hmset
0 0
- Java Code Examples for redis.clients.jedis.Jedis.hmset()
- Java Code Examples for redis.clients.jedis.Jedis
- java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool.getResource()Lredis/clients/jedis/Jedis;
- redis.clients.jedis.exceptions.JedisConnectionException
- centOS下 jedis连接redis失败 redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectExce
- java.lang.NoClassDefFoundError: redis/clients/jedis/exceptions/JedisDataException
- redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException
- redis.clients.jedis.exceptions.JedisConnectionException: java.net.UnknownHostException: 192.168.xxx
- java.lang.NoSuchMethodError: redis.clients.jedis.JedisShardInfo.setTimeout(I)V
- java.lang.NoSuchMethodError: redis.clients.jedis.JedisShardInfo.setTimeout(I)V
- redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refu
- redis客户端-redis.clients.jedis.ShardedJedisPool
- 因缺少jedis.jar包报"java.lang.NoSuchMethodError: redis.clients.jedis.JedisPool..."问题
- spring 注入 redis.clients.jedis.JedisPool 异常
- JAVA EE-操作Jedis.clients的过程
- Spring 集成Redis遇到问题nested exception is java.lang.ClassNotFoundException: redis.clients.jedis.JedisPoo
- Redis Java客户端Jedis
- redis jedis(java)
- 明晰C++内存分配的五种方法的区别
- JPA 开发中遇到的错误
- 类继承中构造函数和析构函数的调用
- Maven使用
- SVN里常见的图标及其含义
- Java Code Examples for redis.clients.jedis.Jedis.hmset()
- 两个ng_model数据交互
- 解析动态联编(上篇)
- HashMap和HashSet解析
- Android自定义Toast的使用
- iOS开发之多线程NSThread,NSOperation,GCD
- 解读VC++编程中的文件操作API和CFile类
- 埃及分数问题-迭代加深搜索与IDA*算法
- (转载)NumPy详细教程