If key does not exist, a new key holding a hash is created.
Time complexity: O(N) (with N being the number of fields) @param key @param hash @return Return OK or Exception if hash is empty
353637383940414243
} public void record(String meetingId, Map<String, String> event) { Jedis jedis = new Jedis(host, port); Long msgid = jedis.incr("global:nextRecordedMsgId"); jedis.hmset("recording:" + meetingId + COLON + msgid, event); jedis.rpush("meeting:" + meetingId + COLON + "recordings", msgid.toString()); } }
3637383940414243444546
@Override public void record(String session, RecordEvent message) { Jedis jedis = redisPool.getResource(); try { Long msgid = jedis.incr("global:nextRecordedMsgId"); jedis.hmset("recording" + COLON + session + COLON + msgid, message.toMap()); jedis.rpush("meeting" + COLON + session + COLON + "recordings", msgid.toString()); } finally { redisPool.returnResource(jedis); } }
4243444546474849505152
} private void record(String session, RecordEvent message) { Jedis jedis = new Jedis(host, port); Long msgid = jedis.incr("global:nextRecordedMsgId"); jedis.hmset("recording" + COLON + session + COLON + msgid, message.toMap()); jedis.rpush("meeting" + COLON + session + COLON + "recordings", msgid.toString()); } @Override public void notify(RecordEvent event) {
673674675676677678679680681682683
public void hmSet(String key, Map<String, Serializable> values) throws Exception { Jedis jedis = null; try { jedis = this.jedisPool.getResource(); jedis.hmset(SafeEncoder.encode(key), encodeMap(values)); LOG.info("hmSet key:" + key + " field:" + values.keySet()); } catch (Exception e) { LOG.error(e.getMessage(), e); this.jedisPool.returnBrokenResource(jedis); throw e;
130131132133134135136137138139140
} Pipeline pipeline = jedis.pipelined(); pipeline.multi(); String redisHtsDatapointKey = toRedisHtsDatapointKey(redisKey); pipeline.hmset(redisHtsDatapointKey, htsMap); String redisHtsDaysKey = toRedisHtsDaysKey(redisKey); for (String dateAsIntText : dates.inverse().keySet()) { pipeline.zrem(redisHtsDaysKey, dateAsIntText); }
216217218219220221222223224225226
values.put("name", name); values.put("followers", "0"); values.put("following", "0"); values.put("posts", "0"); values.put("signup", String.valueOf(System.currentTimeMillis())); trans.hmset("user:" + id, values); trans.exec(); releaseLock(conn, "user:" + llogin, lock); return id; }
321322323324325326327328329330331
data.put("id", String.valueOf(id)); data.put("uid", String.valueOf(uid)); data.put("login", login); trans = conn.multi(); trans.hmset("status:" + id, data); trans.hincrBy("user:" + uid, "posts", 1); trans.exec(); return id; }
8586878889909192939495
} final String endpointToken = channel.getEndpointToken(); final Transaction tx = jedis.multi(); tx.set(endpointToken, Long.toString(channel.getVersion())); tx.set(tokenLookupKey(endpointToken), chid); tx.hmset(chidLookupKey(chid), mapOf(endpointToken, uaid)); tx.sadd(uaidLookupKey(uaid), chid); tx.exec(); return true; } finally { jedisPool.returnResource(jedis);