本文整理汇总了Java中redis.clients.jedis.Jedis.lpush方法的典型用法代码示例。如果您正苦于以下问题:Java Jedis.lpush方法的具体用法?Java Jedis.lpush怎么用?Java Jedis.lpush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redis.clients.jedis.Jedis
的用法示例。
在下文中一共展示了Jedis.lpush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lpushString
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/** 返回的是列表的剩余个数 */
public long lpushString(String key, String value) {
Jedis jedis = null;
boolean success = true;
long ret = 0;
try {
jedis = jedisPool.getResource();
if (jedis == null) {
success = false;
return ret;
}
ret = jedis.lpush(key, value);
} catch (Exception e) {
success = false;
returnBrokenResource(jedis, "lpushString" + key, e);
} finally {
releaseReidsSource(success, jedis);
}
return ret;
}
示例2: rPush
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
* 存储REDIS队列 顺序存储,可设置过期时间,过期时间以秒为单位
*
* @param key redis键名
* @param value 键值
* @param second 过期时间(秒)
*/
public <T> Long rPush(String key, T value, int second) {
Jedis jedis = null;
Long ret = null;
try {
jedis = getConnect();
byte[] bytes = ConvertUtil.serialize(value);
ret = jedis.lpush(key.getBytes(), bytes);
if (second > 0) {
jedis.expire(key, second);
}
} catch (Exception e) {
logger.error("redis rPush data failed , key = " + key, e);
} finally {
close(jedis);
}
return ret;
}
示例3: lpush
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public void lpush(String key, String ele) {
Jedis jedis = null;
try {
jedis = getJedis();
if (jedis == null) {
logger.error("get jedis failed.");
}
jedis.lpush(key, ele);
} catch (JedisConnectionException e) {
if (jedis != null) {
jedis.close();
jedis = null;
}
logger.error("increame connect error:", e);
} finally {
returnJedisResource(jedis);
}
}
示例4: jedistest
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@GET
@Path("jedistest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedistest() {
System.out.println("TEST Jedis ======================================================");
Jedis jedis = new Jedis("localhost", 6379);
jedis.set("foo", "bar");
jedis.get("foo");
jedis.lpush("lll", "a");
jedis.lpush("lll", "b");
jedis.lpush("lll", "c");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.hset("mmm", "abc", "123");
jedis.hset("mmm", "def", "456");
jedis.hgetAll("mmm");
jedis.close();
return "jedistest";
}
示例5: foo
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private static void foo() {
System.out.println("TEST Jedis ======================================================");
Jedis jedis = new Jedis(ip, port);
jedis.set("foo", "bar");
jedis.get("foo");
jedis.lpush("lll", "a");
jedis.lpush("lll", "b");
jedis.lpush("lll", "c");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.hset("mmm", "abc", "123");
jedis.hset("mmm", "def", "456");
jedis.hgetAll("mmm");
jedis.close();
}
示例6: addFirst
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public boolean addFirst(String queueID, ResourceItem e) {
Jedis jedis = null;
if (!lockQueue(queueID)) {
return false;
}
try {
remove(queueID, e.getKey());
jedis = jedisPool.getResource();
jedis.lpush(makePoolQueueKey(queueID), e.getKey());
jedis.hset(makeDataKey(queueID), e.getKey(), JSONObject.toJSONString(e));
} finally {
IOUtils.closeQuietly(jedis);
unLockQueue(queueID);
}
return true;
}
示例7: addFirst
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public boolean addFirst(String queueID, ResourceItem e) {
if (!lockQueue(queueID)) {
return false;
}
@Cleanup Jedis jedis = jedisPool.getResource();
try {
remove(queueID, e.getKey());
jedis.hset(makeDataKey(queueID), e.getKey(), JSONObject.toJSONString(e));
String sliceID = jedis.lpop(makeSliceQueueKey(queueID));
if (isNil(sliceID)) {
sliceID = "1";
}
jedis.lpush(makeSliceQueueKey(queueID), sliceID);
jedis.lpush(makePoolQueueKey(queueID, sliceID), e.getKey());
} finally {
unLockQueue(queueID);
}
return true;
}
示例8: rPushStr
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public void rPushStr(String key, String value, int second) {
Jedis jedis = null;
try {
jedis = getConnect();
jedis.lpush(key, value);
if (second > 0) {
jedis.expire(key, second);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close(jedis);
}
}
示例9: lpush
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
* lpush
* @param key
* @param key
*/
public synchronized static void lpush(String key, String... strings) {
try {
Jedis jedis = RedisUtil.getJedis();
jedis.lpush(key, strings);
jedis.close();
} catch (Exception e) {
_log.error("lpush error : " + e);
}
}
示例10: check
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
protected Result check() throws Exception {
final Map<String, RedisProvider> providers = redisProviders.getProviders();
for (Map.Entry<String, RedisProvider> entry : providers.entrySet()) {
RedisProvider redisProvider = entry.getValue();
Jedis jedis = null;
try {
jedis = redisProvider.get();
final String key = "healthcheck:" + redisProvider.getName();
final int ttl = 3600;
final String checkString = String.format("%d", System.currentTimeMillis());
jedis.lpush(key, checkString);
jedis.expire(key, ttl);
logger.info(kvp("op", "redis_health",
"server", redisProvider.getName(),
"key", key,
"value", checkString,
"ttl", "" + ttl));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return Result.unhealthy(kvp("redis_provider", redisProvider.getName(),
"err", e.getMessage()));
} finally {
redisProvider.closeSafely(jedis);
}
}
return Result.healthy(providers.keySet().toString());
}
示例11: publish
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void publish(String topic, String message) {
Jedis jedis = redisManager.getJedis();
jedis.lpush(topic, message);
redisManager.retureRes(jedis);
}
示例12: lpush
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
* lpush
* @param key
* @param key
*/
public synchronized static void lpush(String key, String... strings) {
try {
Jedis jedis = RedisUtil.getJedis();
jedis.lpush(key, strings);
jedis.close();
} catch (Exception e) {
LOGGER.error("lpush error : " + e);
}
}
示例13: lpush
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public Long lpush(String key, String... strs) {
Jedis jedis = null;
Long res = null;
try {
jedis = pool.getResource();
res = jedis.lpush(key, strs);
} catch (Exception e) {
LOGGER.error(e.getMessage());
} finally {
returnResource(pool, jedis);
}
return res;
}
示例14: jedispolltest
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@GET
@Path("jedispooltest")
@Produces(MediaType.TEXT_HTML + ";charset=utf-8")
public String jedispolltest() {
System.out.println("TEST JedisPool ======================================================");
JedisPoolConfig cfg = new JedisPoolConfig();
cfg.setMaxTotal(5);
cfg.setMaxIdle(1);
cfg.setMaxWaitMillis(10000L);
JedisPool jp = new JedisPool(cfg, "localhost", 6379);
Jedis jedis = jp.getResource();
jedis.set("foo", "bar");
// jedis.close();
jedis = jp.getResource();
jedis.get("foo");
// jedis.close();
jedis = jp.getResource();
jedis.lpush("lll", "a");
jedis.lpush("lll", "b");
jedis.lpush("lll", "c");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.lpop("lll");
// jedis.close();
jedis = jp.getResource();
jedis.hset("mmm", "abc", "123");
jedis.hset("mmm", "def", "456");
jedis.hgetAll("mmm");
jp.close();
return "jedispooltest";
}
示例15: foo2
import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
private static void foo2() {
System.out.println("TEST JedisPool ======================================================");
JedisPoolConfig cfg = new JedisPoolConfig();
cfg.setMaxTotal(5);
cfg.setMaxIdle(1);
cfg.setMaxWaitMillis(10000L);
JedisPool jp = new JedisPool(cfg, ip, port);
Jedis jedis = jp.getResource();
jedis.set("foo", "bar");
// jedis.close();
jedis = jp.getResource();
jedis.get("foo");
// jedis.close();
jedis = jp.getResource();
jedis.lpush("lll", "a");
jedis.lpush("lll", "b");
jedis.lpush("lll", "c");
jedis.lpop("lll");
jedis.lpop("lll");
jedis.lpop("lll");
// jedis.close();
jedis = jp.getResource();
jedis.hset("mmm", "abc", "123");
jedis.hset("mmm", "def", "456");
jedis.hgetAll("mmm");
jp.close();
}