|
| 1 | +package redis.clients.jedis.commands; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | + |
| 5 | +import redis.clients.jedis.args.BitCountOption; |
| 6 | +import redis.clients.jedis.args.BitOP; |
| 7 | +import redis.clients.jedis.params.BitPosParams; |
| 8 | + |
| 9 | +public interface BitCommands { |
| 10 | + |
| 11 | + /** |
| 12 | + * <b><a href="http://redis.io/commands/setbit">SetBit Command</a></b> |
| 13 | + * Sets or clears the bit at offset in the string value stored at key. |
| 14 | + * <p> |
| 15 | + * Time complexity: O(1) |
| 16 | + * @param key |
| 17 | + * @param offset |
| 18 | + * @param value |
| 19 | + * @return The original bit value stored at offset |
| 20 | + */ |
| 21 | + boolean setbit(String key, long offset, boolean value); |
| 22 | + |
| 23 | + /** |
| 24 | + * <b><a href="http://redis.io/commands/getbit">GetBit Command</a></b> |
| 25 | + * Returns the bit value at offset in the string value stored at key. |
| 26 | + * <p> |
| 27 | + * Time complexity: O(1) |
| 28 | + * @param key |
| 29 | + * @param offset |
| 30 | + * @return The bit value stored at offset |
| 31 | + */ |
| 32 | + boolean getbit(String key, long offset); |
| 33 | + |
| 34 | + /** |
| 35 | + * <b><a href="http://redis.io/commands/bitcount">Bitcount Command</a></b> |
| 36 | + * Count the number of set bits (population counting) in a string. |
| 37 | + * @param key |
| 38 | + * @return The number of bits set to 1 |
| 39 | + */ |
| 40 | + long bitcount(String key); |
| 41 | + |
| 42 | + /** |
| 43 | + * <b><a href="http://redis.io/commands/bitcount">Bitcount Command</a></b> |
| 44 | + * Count the number of set bits (population counting) in a string only in an interval start and end. |
| 45 | + * <p> |
| 46 | + * Like for the GETRANGE command start and end can contain negative values in order to index bytes |
| 47 | + * starting from the end of the string, where -1 is the last byte, -2 is the penultimate, and so forth. |
| 48 | + * @param key |
| 49 | + * @param start byte start index |
| 50 | + * @param end byte end index |
| 51 | + * @return The number of bits set to 1 |
| 52 | + */ |
| 53 | + long bitcount(String key, long start, long end); |
| 54 | + |
| 55 | + /** |
| 56 | + * @see StringCommands#bitcount(String, long, long) |
| 57 | + * @param key |
| 58 | + * @param start byte start index |
| 59 | + * @param end byte end index |
| 60 | + * @param option indicate BYTE or BIT |
| 61 | + * @return The number of bits set to 1 |
| 62 | + */ |
| 63 | + long bitcount(String key, long start, long end, BitCountOption option); |
| 64 | + |
| 65 | + /** |
| 66 | + * <b><a href="http://redis.io/commands/bitpos">Bitpos Command</a></b> |
| 67 | + * Return the position of the first bit set to 1 or 0 in a string. |
| 68 | + * @param key |
| 69 | + * @param value the bit value |
| 70 | + * @return The position of the first bit set to 1 or 0 according to the request |
| 71 | + */ |
| 72 | + long bitpos(String key, boolean value); |
| 73 | + |
| 74 | + /** |
| 75 | + * <b><a href="http://redis.io/commands/bitpos">Bitpos Command</a></b> |
| 76 | + * Return the position of the first bit set to 1 or 0 in a string. |
| 77 | + * @param key |
| 78 | + * @param value the bit value |
| 79 | + * @param params {@link BitPosParams} |
| 80 | + * @return The position of the first bit set to 1 or 0 according to the request |
| 81 | + */ |
| 82 | + long bitpos(String key, boolean value, BitPosParams params); |
| 83 | + |
| 84 | + /** |
| 85 | + * <b><a href="http://redis.io/commands/bitfield">Bitfield Command</a></b> |
| 86 | + * The command treats a Redis string as an array of bits, and is capable of addressing specific integer |
| 87 | + * fields of varying bit widths and arbitrary non (necessary) aligned offset. |
| 88 | + * @param key |
| 89 | + * @param arguments may be used with optional arguments |
| 90 | + * @return A List of results |
| 91 | + */ |
| 92 | + List<Long> bitfield(String key, String...arguments); |
| 93 | + |
| 94 | + /** |
| 95 | + * The readonly version of {@link StringCommands#bitfield(String, String...) BITFIELD} |
| 96 | + */ |
| 97 | + List<Long> bitfieldReadonly(String key, String...arguments); |
| 98 | + |
| 99 | + /** |
| 100 | + * <b><a href="http://redis.io/commands/bitop">Bitop Command</a></b> |
| 101 | + * Perform a bitwise operation between multiple keys (containing string values) and store the result in the destKey. |
| 102 | + * @param op can be AND, OR, XOR or NOT |
| 103 | + * @param destKey |
| 104 | + * @param srcKeys |
| 105 | + * @return The size of the string stored in the destKey |
| 106 | + */ |
| 107 | + long bitop(BitOP op, String destKey, String... srcKeys); |
| 108 | + |
| 109 | +} |
0 commit comments