@Override public Long lPush(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values))); return null; } return connection.getJedis().lpush(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override Response<Long> execute(Pipeline jedisPipeline) throws DynoException { return jedisPipeline.lpush(key, string); }
@Override public Object doInRedis(RedisConnection connection) throws DataAccessException { Jedis jedis = (Jedis) connection.getNativeConnection(); jedis.pipelined().lpush("", ""); return null; } };
@Override public Response<Long> lpush(String key, String... string) { String command = "lpush"; return instrumented(command, payloadSize(string), () -> delegated.lpush(key, string)); }
@Override public Response<Long> lpush(byte[] key, byte[]... string) { String command = "lpush"; return instrumented(command, payloadSize(string), () -> delegated.lpush(key, string)); }
private void writeUsingListCommand( KV<String, String> record, Method method, Long expireTime) { String key = record.getKey(); String value = record.getValue(); if (Method.LPUSH == method) { pipeline.lpush(key, value); } else if (Method.RPUSH == method) { pipeline.rpush(key, value); } setExpireTimeWhenRequired(key, expireTime); }
@Override Long execute() { Pipeline pipeline = jedis.getShard(key).pipelined(); Response<Long> result = pipeline.lpush(key, value); // 修剪列表元素, 如果 size - 1 比 end 下标还要大,Redis将 size 的值设置为 end 。 pipeline.ltrim(key, 0, size - 1); pipeline.sync(); return result.get(); } }.getResult();
@Override public Long lPush(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values))); return null; } return connection.getJedis().lpush(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long lPush(byte[] key, byte[]... values) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(values, "Values must not be null!"); Assert.noNullElements(values, "Values must not contain null elements!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().lpush(key, values))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().lpush(key, values))); return null; } return connection.getJedis().lpush(key, values); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
private Response<?> writeRecord(RedisMutation mutation) { switch (mutation.getMethod()) { case APPEND: return pipeline.append(mutation.getKey(), mutation.getValue()); case SET: return pipeline.set(mutation.getKey(), mutation.getValue()); case LPUSH: return pipeline.lpush(mutation.getKey(), mutation.getValue()); case RPUSH: return pipeline.rpush(mutation.getKey(), mutation.getValue()); case SADD: return pipeline.sadd(mutation.getKey(), mutation.getValue()); case ZADD: return pipeline.zadd(mutation.getKey(), mutation.getScore(), mutation.getValue()); default: throw new UnsupportedOperationException( String.format("Not implemented writing records for %s", mutation.getMethod())); } }