java jedis.incr()_Java Jedis.incr方法代碼示例

本文整理匯總了Java中redis.clients.jedis.Jedis.incr方法的典型用法代碼示例。如果您正苦於以下問題:Java Jedis.incr方法的具體用法?Java Jedis.incr怎麽用?Java Jedis.incr使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Jedis的用法示例。

在下文中一共展示了Jedis.incr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: incr

​點讚 5

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public Long incr(String key) {

Jedis jedis = null;

boolean success = true;

long ret = -1;

try {

jedis = jedisPool.getResource();

if (jedis == null) {

success = false;

return ret;

}

ret = jedis.incr(key);

} catch (Exception e) {

success = false;

returnBrokenResource(jedis, "incr:" + key, e);

} finally {

releaseReidsSource(success, jedis);

}

return ret;

}

開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:20,

示例2: checkJedisIsReusedWhenReturned

​點讚 4

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

@Test

public void checkJedisIsReusedWhenReturned() {

JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());

Jedis jedis = pool.getResource();

jedis.auth("foobared");

jedis.set("foo", "0");

pool.returnResource(jedis);

jedis = pool.getResource();

jedis.auth("foobared");

jedis.incr("foo");

pool.returnResource(jedis);

pool.destroy();

assertTrue(pool.isClosed());

}

開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:17,

示例3: fetchDailyUUID

​點讚 3

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public Long fetchDailyUUID(String key, Integer length, Boolean haveDay) {

Jedis jedis = null;

try {

jedis = redisConnection.getJedis();

jedis.select(dbIndex);

Calendar now = new GregorianCalendar();

String day = df.format(now.getTime());

key = key + "_" + day;

Long num = jedis.incr(key);

//設置 key 過期時間

if (num == 1) {

jedis.expire(key, (24 - now.get(Calendar.HOUR_OF_DAY)) * 3600 + 1800);

}

if (haveDay) {

return createUUID(num, day, length);

} else {

return num;

}

} finally {

if (jedis != null) {

jedis.close();

}

}

}

開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:25,

示例4: fetchUUID

​點讚 3

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public Long fetchUUID(String key, Integer length, Boolean haveDay) {

Jedis jedis = null;

try {

jedis = redisConnection.getJedis();

jedis.select(dbIndex);

Calendar now = new GregorianCalendar();

Long num = jedis.incr(key);

if (haveDay) {

String day = df.format(now.getTime());

return createUUID(num, day, length);

} else {

return num;

}

} finally {

if (jedis != null) {

jedis.close();

}

}

}

開發者ID:gaochao2000,項目名稱:redis_util,代碼行數:21,

示例5: increame

​點讚 3

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public long increame(String key) {

Jedis jedis = null;

try {

jedis = getJedis();

if (jedis != null) {

return jedis.incr(key);

} else {

logger.error("increame opt connection null error!");

}

} catch (JedisConnectionException e) {

if (jedis != null) {

jedis.close();

jedis = null;

}

logger.error("increame connect error:", e);

} finally {

returnJedisResource(jedis);

}

return 0L;

}

開發者ID:Zephery,項目名稱:newblog,代碼行數:21,

示例6: main

​點讚 3

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public static void main(String[] args) throws InterruptedException {

Bench bench = new JedisBench() {

@Override

public void executeOperation(String data, JedisPool benchInstance, int threadNumber, int iteration,

MetricRegistry metrics) {

Jedis jedis = benchInstance.getResource();

Timer.Context time = metrics.timer("incr").time();

jedis.incr("incr_" + threadNumber + "_" + iteration);

time.stop();

jedis.close();

}

};

Benchmark benchmark = new Benchmark(bench);

benchmark.run(args);

}

開發者ID:redisson,項目名稱:redisson-benchmark,代碼行數:19,

示例7: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public long incr(String key) {

Jedis jedis = jedisPool.getResource();

Long result = null;

try {

result = jedis.incr(key);

} catch (Exception e) {

jedisPool.returnBrokenResource(jedis);

} finally {

jedisPool.returnResource(jedis);

}

return result;

}

開發者ID:melonlee,項目名稱:LazyREST,代碼行數:13,

示例8: checkPoolRepairedWhenJedisIsBroken

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

@Test

public void checkPoolRepairedWhenJedisIsBroken() {

JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());

Jedis jedis = pool.getResource();

jedis.auth("foobared");

jedis.quit();

pool.returnBrokenResource(jedis);

jedis = pool.getResource();

jedis.auth("foobared");

jedis.incr("foo");

pool.returnResource(jedis);

pool.destroy();

assertTrue(pool.isClosed());

}

開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:16,

示例9: checkPoolOverflow

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

@Test(expected = JedisException.class)

public void checkPoolOverflow() {

GenericObjectPoolConfig config = new GenericObjectPoolConfig();

config.setMaxTotal(1);

config.setBlockWhenExhausted(false);

JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort());

Jedis jedis = pool.getResource();

jedis.auth("foobared");

jedis.set("foo", "0");

Jedis newJedis = pool.getResource();

newJedis.auth("foobared");

newJedis.incr("foo");

}

開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:15,

示例10: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

/**

* 自增

*

* @param key key

* @return 0:失敗,非0:成功

*/

public Long incr(String key) {

Jedis jedis = null;

try {

jedis = getConnect();

return jedis.incr(key);

} catch (Exception e) {

logger.error("redis getRedisData data failed!", e);

return 0L;

} finally {

close(jedis);

}

}

開發者ID:TwoDragonLake,項目名稱:tdl-seckill,代碼行數:20,

示例11: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

@Override

public Long incr(String key) {

Jedis jedis = jedisPool.getResource();

Long result = jedis.incr(key);

jedis.close();

return result;

}

開發者ID:mmdsyl,項目名稱:BLOG-Microservice,代碼行數:8,

示例12: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

/**

* incr

* @param key

* @return value

*/

public synchronized static Long incr(String key) {

Jedis jedis = getJedis();

if (null == jedis) {

return null;

}

long value = jedis.incr(key);

jedis.close();

return value;

}

開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:15,

示例13: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

/**

* @Description 自增生成ID

*

* @author butterfly

* @param key

* @param value

* @throws Exception

*/

public Long incr(String key) throws Exception {

Jedis jedis = null;

try {

jedis = jedisPool.getResource();

Long index = jedis.incr(key);

return index;

} catch (Exception ex) {

throw ex;

} finally {

// 返還到連接池

if (null != jedis)

jedis.close();

}

}

開發者ID:butter-fly,項目名稱:belling-redis-id-generator,代碼行數:23,

示例14: incr

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

@Override

public Long incr(String key) {

Jedis jedis = null;

Long res = null;

try {

jedis = pool.getResource();

res = jedis.incr(key);

} catch (Exception e) {

LOGGER.error(e.getMessage());

} finally {

returnResource(pool, jedis);

}

return res;

}

開發者ID:wxiaoqi,項目名稱:ace-cache,代碼行數:16,

示例15: increase

​點讚 2

import redis.clients.jedis.Jedis; //導入方法依賴的package包/類

public Long increase(String key) {

Jedis jedis = null;

Long var3;

try {

jedis = pool.getResource();

var3 = jedis.incr(key);

} catch (Exception var7) {

throw new RuntimeException(var7);

} finally {

pool.returnResourceObject(jedis);

}

return var3;

}

開發者ID:bitstd,項目名稱:bitstd,代碼行數:16,

注:本文中的redis.clients.jedis.Jedis.incr方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值