redis.clients.jedis.Jedis.append()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(221)

本文整理了Java中redis.clients.jedis.Jedis.append()方法的一些代码示例,展示了Jedis.append()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.append()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:append

Jedis.append介绍

[英]If the key already exists and is a string, this command appends the provided value at the end of the string. If the key does not exist it is created and set as an empty string, so APPEND will be very similar to SET in this special case.

Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.
[中]如果键已经存在并且是字符串,则此命令会在字符串末尾追加提供的值。如果键不存在,它将被创建并设置为空字符串,因此APPEND与此特殊情况下的set非常相似。
时间复杂度:O(1)。假设附加值很小,并且已经存在的值是任意大小的,则摊销时间复杂度为O(1),因为Redis使用的动态字符串库将使每次重新分配时可用的可用空间加倍。

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public Long execute(Jedis connection) {
  return connection.append(key, value);
 }
}.run(key);

代码示例来源:origin: sohutv/cachecloud

@Override
 public Long execute(Jedis connection) {
  return connection.append(key, value);
 }
}.runBinary(key);

代码示例来源:origin: sohutv/cachecloud

@Override
public Long append(byte[] key, byte[] value) {
 Jedis j = getShard(key);
 return j.append(key, value);
}

代码示例来源:origin: sohutv/cachecloud

@Override
public Long append(String key, String value) {
 Jedis j = getShard(key);
 return j.append(key, value);
}

代码示例来源:origin: Netflix/conductor

@Override
public Long append(String key, String value) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.append(key, value);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testAppend() throws Exception {
  try (Jedis jedis = pool.getResource()) {
    Assert.assertEquals(5, (long)jedis.append("appendKey1", "Hello"));
    Assert.assertEquals(12, (long)jedis.append("appendKey1", " World!"));
    jcache().put("setDataTypeKey", new HashSet<String>(Arrays.asList("1", "2")));
    try {
      jedis.append("setDataTypeKey", "");
      assert false : "Exception has to be thrown!";
    }
    catch (JedisDataException e) {
      assertTrue(e.getMessage().startsWith("WRONGTYPE"));
    }
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public Long append(byte[] key, byte[] value) {
  Assert.notNull(key, "Key must not be null!");
  Assert.notNull(value, "Value must not be null!");
  try {
    if (isPipelined()) {
      pipeline(connection.newJedisResult(connection.getRequiredPipeline().append(key, value)));
      return null;
    }
    if (isQueueing()) {
      transaction(connection.newJedisResult(connection.getRequiredTransaction().append(key, value)));
      return null;
    }
    return connection.getJedis().append(key, value);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    return jedis.append(key, value);
  }
});

代码示例来源:origin: yrain/smart-cache

@Override
  Long doInJedis(Jedis jedis) {
    return jedis.append(key, value);
  }
});

代码示例来源:origin: apache/servicemix-bundles

@Override
 public Long execute(Jedis connection) {
  return connection.append(key, value);
 }
}.runBinary(key);

代码示例来源:origin: apache/servicemix-bundles

@Override
 public Long execute(Jedis connection) {
  return connection.append(key, value);
 }
}.run(key);

代码示例来源:origin: com.netflix.dyno/dyno-jedis

@Override
  public Long execute(Jedis client, ConnectionContext state) {
    return client.append(key, value);
  }
});

代码示例来源:origin: io.leopard/leopard-redis

@Override
public Long append(String key, String value) {
  return jedis.append(key, value);
}

代码示例来源:origin: yrain/smart-cache

@Override
  Long doInJedis(Jedis jedis) {
    return jedis.append(key, value);
  }
});

代码示例来源:origin: mindwind/craft-atom

private Long append0(Jedis j, String key, String value) {
  return j.append(key, value);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Long append(final byte[] key, final byte[] value) {
 Jedis j = getShard(key);
 return j.append(key, value);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public Long append(final String key, final String value) {
 Jedis j = getShard(key);
 return j.append(key, value);
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Long append(String key, String value) {
 String command = "append";
 return instrumented(command, payloadSize(value), () -> delegated.append(key, value));
}

代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis

@Override
public Long append(byte[] key, byte[] value) {
 String command = "append";
 return instrumented(command, payloadSize(value), () -> delegated.append(key, value));
}

代码示例来源:origin: com.netflix.conductor/conductor-redis-persistence

@Override
public Long append(String key, String value) {
 Jedis jedis = null;
  try {
   jedis = jedisPool.getResource();
   return jedis.append(key, value);
  } finally {
   if (jedis != null)
    jedis.close();
  }
}

相关文章

Jedis类方法