com.lordofthejars.nosqlunit.redis.embedded
Class StringDatatypeOperations

java.lang.Object
  extended by com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations
      extended by com.lordofthejars.nosqlunit.redis.embedded.StringDatatypeOperations
All Implemented Interfaces:
RedisDatatypeOperations

public class StringDatatypeOperations
extends ExpirationDatatypeOperations
implements RedisDatatypeOperations


Nested Class Summary
 
Nested classes/interfaces inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations
ExpirationDatatypeOperations.TtlState
 
Field Summary
protected  Map<ByteBuffer,ByteBuffer> simpleTypes
           
protected static String STRING
           
 
Fields inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations
expirationsInMillis, NO_EXPIRATION
 
Constructor Summary
StringDatatypeOperations()
           
 
Method Summary
 Long append(byte[] key, byte[] value)
          If the key already exists and is a string, this command appends the provided value at the end of the string.
 Long decr(byte[] key)
          Decrement the number stored at key by one.
 Long decrBy(byte[] key, long integer)
          IDECRBY work just like INCR but instead to decrement by 1 the decrement is integer.
 Long del(byte[]... keys)
           
 boolean exists(byte[] key)
           
 void flushAllKeys()
           
 byte[] get(byte[] key)
           
 Boolean getbit(byte[] key, long offset)
          Returns the bit value at offset in the string value stored at key
 long getNumberOfKeys()
           
 byte[] getrange(byte[] key, long startOffset, long endOffset)
           
 byte[] getSet(byte[] key, byte[] value)
           
 Long incr(byte[] key)
          Increment the number stored at key by one.
 Long incrBy(byte[] key, long integer)
          INCRBY work just like INCR but instead to increment by 1 the increment is integer.
 List<byte[]> keys()
           
 List<byte[]> mget(byte[]... keys)
           
 String mset(byte[]... keysvalues)
           
 Long msetnx(byte[]... keysvalues)
           
 String rename(byte[] oldKey, byte[] newKey)
           
 boolean renameKey(byte[] key, byte[] newKey)
           
 String set(byte[] key, byte[] value)
           
 Boolean setbit(byte[] key, long offset, byte[] value)
          Sets or clears the bit at offset in the string value stored at key
 String setex(byte[] key, int seconds, byte[] value)
           
 Long setnx(byte[] key, byte[] value)
           
 Long setrange(byte[] key, long offset, byte[] value)
           
 List<byte[]> sort(byte[] key)
           
 int strlen(byte[] key)
           
 byte[] substr(byte[] key, int start, int end)
          Return a subset of the string from offset start to offset end (both offsets are inclusive).
 String type()
           
 
Methods inherited from class com.lordofthejars.nosqlunit.redis.embedded.ExpirationDatatypeOperations
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, renameTtlKey, timedoutState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.lordofthejars.nosqlunit.redis.embedded.RedisDatatypeOperations
addExpirationAt, addExpirationTime, remainingTime, removeExpiration, timedoutState
 

Field Detail

STRING

protected static final String STRING
See Also:
Constant Field Values

simpleTypes

protected Map<ByteBuffer,ByteBuffer> simpleTypes
Constructor Detail

StringDatatypeOperations

public StringDatatypeOperations()
Method Detail

append

public Long append(byte[] key,
                   byte[] value)
If the key already exists and is a string, this command appends the provided value at the end of the string. If the key does not exist it is created and set as an empty string, so APPEND will be very similar to SET in this special case.

Time complexity: O(1). The amortized time complexity is O(1) assuming the appended value is small and the already present value is of any size, since the dynamic string library used by Redis will double the free space available on every reallocation.

Parameters:
key -
value -
Returns:
Integer reply, specifically the total length of the string after the append operation.

decr

public Long decr(byte[] key)
Decrement the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the decrement operation.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

Time complexity: O(1)

Parameters:
key -
Returns:
Integer reply, this commands will reply with the new value of key after the increment.
See Also:
incr(byte[]), incrBy(byte[], long), decrBy(byte[], long)

decrBy

public Long decrBy(byte[] key,
                   long integer)
IDECRBY work just like INCR but instead to decrement by 1 the decrement is integer.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

Parameters:
key -
integer -
Returns:
Integer reply, this commands will reply with the new value of key after the increment.
See Also:
incr(byte[]), decr(byte[]), incrBy(byte[], long)

incrBy

public Long incrBy(byte[] key,
                   long integer)
INCRBY work just like INCR but instead to increment by 1 the increment is integer.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

Parameters:
key -
integer -
Returns:
Integer reply, this commands will reply with the new value of key after the increment.
See Also:
incr(byte[]), decr(byte[]), decrBy(byte[], long)

incr

public Long incr(byte[] key)
Increment the number stored at key by one. If the key does not exist or contains a value of a wrong type, set the key to the value of "0" before to perform the increment operation.

INCR commands are limited to 64 bit signed integers.

Note: this is actually a string operation, that is, in Redis there are not "integer" types. Simply the string stored at the key is parsed as a base 10 64 bit signed integer, incremented, and then converted back as a string.

Parameters:
key -
Returns:
Integer reply, this commands will reply with the new value of key after the increment.
See Also:
incrBy(byte[], long), decr(byte[]), decrBy(byte[], long)

getbit

public Boolean getbit(byte[] key,
                      long offset)
Returns the bit value at offset in the string value stored at key

Parameters:
key -
offset -
Returns:

setbit

public Boolean setbit(byte[] key,
                      long offset,
                      byte[] value)
Sets or clears the bit at offset in the string value stored at key

Parameters:
key -
offset -
value -
Returns:

setrange

public Long setrange(byte[] key,
                     long offset,
                     byte[] value)

getrange

public byte[] getrange(byte[] key,
                       long startOffset,
                       long endOffset)

mset

public String mset(byte[]... keysvalues)

msetnx

public Long msetnx(byte[]... keysvalues)

strlen

public int strlen(byte[] key)

rename

public String rename(byte[] oldKey,
                     byte[] newKey)

mget

public List<byte[]> mget(byte[]... keys)

get

public byte[] get(byte[] key)

getSet

public byte[] getSet(byte[] key,
                     byte[] value)

set

public String set(byte[] key,
                  byte[] value)

setnx

public Long setnx(byte[] key,
                  byte[] value)

setex

public String setex(byte[] key,
                    int seconds,
                    byte[] value)

substr

public byte[] substr(byte[] key,
                     int start,
                     int end)
Return a subset of the string from offset start to offset end (both offsets are inclusive). Negative offsets can be used in order to provide an offset starting from the end of the string. So -1 means the last char, -2 the penultimate and so forth.

The function handles out of range requests without raising an error, but just limiting the resulting range to the actual length of the string.

Parameters:
key -
start -
end -
Returns:
Bulk reply

getNumberOfKeys

public long getNumberOfKeys()
Specified by:
getNumberOfKeys in interface RedisDatatypeOperations

flushAllKeys

public void flushAllKeys()
Specified by:
flushAllKeys in interface RedisDatatypeOperations

del

public Long del(byte[]... keys)
Specified by:
del in interface RedisDatatypeOperations

exists

public boolean exists(byte[] key)
Specified by:
exists in interface RedisDatatypeOperations

renameKey

public boolean renameKey(byte[] key,
                         byte[] newKey)
Specified by:
renameKey in interface RedisDatatypeOperations

keys

public List<byte[]> keys()
Specified by:
keys in interface RedisDatatypeOperations

type

public String type()
Specified by:
type in interface RedisDatatypeOperations

sort

public List<byte[]> sort(byte[] key)
Specified by:
sort in interface RedisDatatypeOperations


Copyright © 2012. All Rights Reserved.