Package redis.clients.jedis

Examples of redis.clients.jedis.Jedis.incr()


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

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here


  jedis.quit();
  pool.returnBrokenResource(jedis);

  jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
  assertTrue(pool.isClosed());
    }
View Full Code Here

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

  Jedis newJedis = pool.getResource();
  newJedis.auth("foobared");
  newJedis.incr("foo");
    }

    @Test
    public void securePool() {
  JedisPoolConfig config = new JedisPoolConfig();
View Full Code Here

    } catch (InterruptedException e) {
    }
    Jedis j = new Jedis("localhost");
    j.auth("foobared");
    for (int i = 0; i < 5; i++) {
        j.incr("foobared");
    }
    j.disconnect();
      }
  }).start();
View Full Code Here

        return string;
    }

    public Long incr() {
        Jedis jedis = getResource();
        Long incr = jedis.incr(key());
        returnResource(jedis);
        return incr;
    }

    public List<Object> multi(TransactionBlock transaction) {
View Full Code Here

        Long data = null;
        Jedis jedis = null;
        try {
            jedis = this.jedisPool.getResource();
            long begin = System.currentTimeMillis();
            data = jedis.incr(SafeEncoder.encode(key));
            long end = System.currentTimeMillis();
            LOG.info("getValueFromCache spends: " + (end - begin)
                    + " millionseconds.");
        } catch (Exception e) {
            // do jedis.quit() and jedis.disconnect()
View Full Code Here

      String key = key(repository, KeyType.counter, null);
      String val = jedis.get(key);
      if (isNull(val)) {
        jedis.set(key, "0");
      }
      long ticketNumber = jedis.incr(key);
      return ticketNumber;
    } catch (JedisException e) {
      log.error("failed to assign new ticket id in Redis @ " + getUrl(), e);
      pool.returnBrokenResource(jedis);
      jedis = null;
View Full Code Here

            lastId = id;
          }
        }
        jedis.set(key, "" + lastId);
      }
      long ticketNumber = jedis.incr(key);
      return ticketNumber;
    } catch (JedisException e) {
      log.error("failed to assign new ticket id in Redis @ " + getUrl(), e);
      pool.returnBrokenResource(jedis);
      jedis = null;
View Full Code Here


    public String create(PasteItem item) {
        Jedis jedis = jedisPool.getResource();
        try {
            long pasteIndex = jedis.incr("pasteIndex");
            String tokenId = TokenGenerator.generateToken(tokenLength);
            item.setItemId(tokenId);
            item.setPasteIndex(pasteIndex);

            logger.info("Creating paste with itemId: " + tokenId + " pasteIndex: " + pasteIndex);
View Full Code Here

      Jedis jedis = new Jedis(redisConfig);
      String redirectUrl = jedis.get("fromkey:" + key);
      if (redirectUrl == null) {
         notFound();
      }
      jedis.incr("count:" + key);
      redirect(redirectUrl, true);
   }

   private static String newUrl(String longurl, Jedis jedis) {
      String niceUrl = isValidUrl(longurl) ? longurl : "http://" + longurl;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.