redis.clients.jedis.BitOP Java Examples

The following examples show how to use redis.clients.jedis.BitOP. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BitCommandsTest.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Test
public void bitOp() {
  jedis.set("key1", "\u0060");
  jedis.set("key2", "\u0044");

  jedis.bitop(BitOP.AND, "resultAnd", "key1", "key2");
  String resultAnd = jedis.get("resultAnd");
  assertEquals("\u0040", resultAnd);

  jedis.bitop(BitOP.OR, "resultOr", "key1", "key2");
  String resultOr = jedis.get("resultOr");
  assertEquals("\u0064", resultOr);

  jedis.bitop(BitOP.XOR, "resultXor", "key1", "key2");
  String resultXor = jedis.get("resultXor");
  assertEquals("\u0024", resultXor);

  jedis.del("resultAnd");
  jedis.del("resultOr");
  jedis.del("resultXor");
  jedis.del("key1");
  jedis.del("key2");
}
 
Example #2
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(final BitOP op, final byte[] destKey, final byte[]... srcKeys) {
	checkArgumentsSpecification(destKey);
	checkArgumentsSpecification(srcKeys);
	byte[][] wholeKeys = KeyMergeUtil.merge(destKey, srcKeys);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.bitop(op, destKey, srcKeys);
		}
	}.runBinary(wholeKeys.length, wholeKeys);
}
 
Example #3
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(BitOP op, String destKey, String... srcKeys) {
  Span span = helper.buildSpan("bitop");
  span.setTag("destKey", destKey);
  span.setTag("srcKeys", Arrays.toString(srcKeys));
  try {
    return super.bitop(op, destKey, srcKeys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #4
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
  Span span = helper.buildSpan("bitop");
  span.setTag("destKey", Arrays.toString(destKey));
  span.setTag("srcKeys", TracingHelper.toString(srcKeys));
  try {
    return super.bitop(op, destKey, srcKeys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #5
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(BitOP op, String destKey, String... srcKeys) {
  Span span = helper.buildSpan("bitop");
  span.setTag("destKey", destKey);
  span.setTag("srcKeys", Arrays.toString(srcKeys));
  try {
    return super.bitop(op, destKey, srcKeys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #6
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
  Span span = helper.buildSpan("bitop");
  span.setTag("destKey", Arrays.toString(destKey));
  span.setTag("srcKeys", TracingHelper.toString(srcKeys));
  try {
    return super.bitop(op, destKey, srcKeys);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #7
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public Long bitop(final BitOP op, final String destKey, final String... srcKeys) {
	checkArgumentsSpecification(destKey);
	checkArgumentsSpecification(srcKeys);
	String[] mergedKeys = KeyMergeUtil.merge(destKey, srcKeys);

	return new EnhancedJedisClusterCommand<Long>(connectionHandler, maxAttempts) {
		@Override
		public Long doExecute(Jedis connection) {
			return connection.bitop(op, destKey, srcKeys);
		}
	}.run(mergedKeys.length, mergedKeys);
}
 
Example #8
Source File: BitCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void bitOpNot() {
  jedis.del("key");
  jedis.setbit("key", 0, true);
  jedis.setbit("key", 4, true);

  jedis.bitop(BitOP.NOT, "resultNot", "key");

  String resultNot = jedis.get("resultNot");
  assertEquals("\u0077", resultNot);

  jedis.del("key");
  jedis.del("resultNot");
}
 
Example #9
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 4 votes vote down vote up
private void bitxor0(String destkey, String... keys) {
	t.bitop(BitOP.XOR, destkey, keys);
}
 
Example #10
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 4 votes vote down vote up
private void bitor0(String destkey, String... keys) {
	t.bitop(BitOP.OR, destkey, keys);
}
 
Example #11
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 4 votes vote down vote up
private void bitand0(String destkey, String... keys) {
	t.bitop(BitOP.AND, destkey, keys);
}
 
Example #12
Source File: DefaultRedisTransaction.java    From craft-atom with MIT License 4 votes vote down vote up
private void bitnot0(String destkey, String key) {
	t.bitop(BitOP.NOT, destkey, key);
}
 
Example #13
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long bitxor0(Jedis j, String destkey, String... keys) {
	return j.bitop(BitOP.XOR, destkey, keys);
}
 
Example #14
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long bitor0(Jedis j, String destkey, String... keys) {
	return j.bitop(BitOP.OR, destkey, keys);
}
 
Example #15
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long bitand0(Jedis j, String destkey, String... keys) {
	return j.bitop(BitOP.AND, destkey, keys);
}
 
Example #16
Source File: DefaultRedis.java    From craft-atom with MIT License 4 votes vote down vote up
private Long bitnot0(Jedis j, String destkey, String key) {
	return j.bitop(BitOP.NOT, destkey, key);
}
 
Example #17
Source File: MultiKeyJedisClusterCommands.java    From cachecloud with Apache License 2.0 votes vote down vote up
Long bitop(BitOP op, final String destKey, String... srcKeys); 
Example #18
Source File: MultiKeyBinaryJedisClusterCommands.java    From cachecloud with Apache License 2.0 votes vote down vote up
Long bitop(BitOP op, final byte[] destKey, byte[]... srcKeys); 
Example #19
Source File: Commands.java    From cachecloud with Apache License 2.0 votes vote down vote up
void bitop(BitOP op, final String destKey, String... srcKeys); 
Example #20
Source File: MultiKeyBinaryCommands.java    From cachecloud with Apache License 2.0 votes vote down vote up
Long bitop(BitOP op, final byte[] destKey, byte[]... srcKeys); 
Example #21
Source File: MultiKeyCommandsPipeline.java    From cachecloud with Apache License 2.0 votes vote down vote up
Response<Long> bitop(BitOP op, final String destKey, String... srcKeys); 
Example #22
Source File: MultiKeyBinaryRedisPipeline.java    From cachecloud with Apache License 2.0 votes vote down vote up
Response<Long> bitop(BitOP op, final byte[] destKey, byte[]... srcKeys);