Package redis.clients.jedis

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


        if (schemaKey == null) {
          final String doc = schema.toString();
          schemaKey = createSchemaKey(schema, doc);
          j.set(schemaKey + z, doc);
        }
        String watch = j.watch(row + v);
        if (!watch.equals("OK")) {
          return false;
        }
        String versionStr = j.get(row + v);
        if ((versionStr == null && version != 0) || // row missing but version set
View Full Code Here


    @Override
    public void appendEvents(String type, final DomainEventStream events) {
        Jedis jedis = redisConnectionProvider.newConnection();
        DomainEventMessage firstEvent = events.peek();
        final byte[] key = (type + "." + firstEvent.getAggregateIdentifier()).getBytes(IOUtils.UTF8);
        jedis.watch(key);
        Long eventCount = jedis.llen(key);
        if ((firstEvent.getSequenceNumber() != 0 && eventCount == null)
                || firstEvent.getSequenceNumber() != eventCount) {
            jedis.unwatch();
            throw new ConcurrencyException(
View Full Code Here

    @Override
    public String updateVersion(final String endpointToken, final long newVersion) throws VersionException, ChannelNotFoundException {
        final Jedis jedis = jedisPool.getResource();
        try {
            jedis.watch(endpointToken);
            final String versionString = jedis.get(endpointToken);
            if (versionString == null) {
                throw channelNotFoundException(endpointToken);
            }
            final long currentVersion = Long.valueOf(versionString);
View Full Code Here

      long ts1 = System.currentTimeMillis();
        boolean brokenJedis = false;
        ShardedJedis jedis = getResource();
        try {
            Jedis j = jedis.getShard(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE);
            j.watch(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE);
            if (checkOldState) {
                String oldStateStr = j.hget(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE);
                if (oldState == null && oldStateStr != null) {
                    throw new SetFailedException();
                }
View Full Code Here

        try {
            if (jedis.exists(redisKey)) {
                return false;
            }
            Jedis j = jedis.getShard(redisKey);
            j.watch(redisKey);
          
            String val = j.get(redisKey);
            if (val != null) {
                j.unwatch();
                return false;
View Full Code Here

     long ts1 = System.currentTimeMillis();
     boolean brokenJedis = false;
     ShardedJedis jedis = getResource();
     try {
       Jedis j = jedis.getShard(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE);
       j.watch(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE);
       if (checkOldState) {
         String oldStateStr = j.hget(queueUrl + "-" + shard + "-" + CQSConstants.REDIS_STATE, CQSConstants.REDIS_STATE);
         if (oldState == null && oldStateStr != null) {
           throw new SetFailedException();
         }
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.