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;