com.yahoo.ycsb.memcached
Class MemcachedWrapper

java.lang.Object
  extended by com.yahoo.ycsb.DataStore
      extended by com.yahoo.ycsb.memcached.Memcached
          extended by com.yahoo.ycsb.memcached.MemcachedWrapper

public class MemcachedWrapper
extends Memcached

Wrapper around a "real" DB that measures latencies and counts return codes.


Constructor Summary
MemcachedWrapper(Memcached memcached)
           
 
Method Summary
 int add(java.lang.String key, java.lang.Object value)
          Adds a keys value in the database if the key doesn't already exist
 int append(java.lang.String key, long cas, java.lang.Object value)
          Appends a value to a keys current value
 int cas(java.lang.String key, long cas, java.lang.Object value)
          Stores a new value if the operation has the correct cas value
 void cleanup()
          Cleanup any state for this Memcached.
 int decr(java.lang.String key, java.lang.Object value)
          Decrement a keys value in the database
 int delete(java.lang.String key)
          Delete a key from the database
 int get(java.lang.String key, java.lang.Object value)
          Get a key's value from the database.
 java.util.Properties getProperties()
          Get the set of properties for this Memcached.
 long gets(java.lang.String key)
          Gets a unique cas value for a key.
 int incr(java.lang.String key, java.lang.Object value)
          Increment a keys value in the database
 void init()
          Initialize any state for this Memcached.
 int prepend(java.lang.String key, long cas, java.lang.Object value)
          Prepends a value to a keys current value
 int replace(java.lang.String key, java.lang.Object value)
          Replaces the value of a key already in the database.
 int set(java.lang.String key, java.lang.Object value)
          Insert a record in the database.
 void setProperties(java.util.Properties p)
          Set the properties for this Memcached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemcachedWrapper

public MemcachedWrapper(Memcached memcached)
Method Detail

setProperties

public void setProperties(java.util.Properties p)
Set the properties for this Memcached.

Overrides:
setProperties in class DataStore

getProperties

public java.util.Properties getProperties()
Get the set of properties for this Memcached.

Overrides:
getProperties in class DataStore

init

public void init()
          throws DataStoreException
Initialize any state for this Memcached. Called once per Memcached instance; there is one Memcached instance per client thread.

Overrides:
init in class DataStore
Throws:
DataStoreException

cleanup

public void cleanup()
             throws DataStoreException
Cleanup any state for this Memcached. Called once per Memcached instance; there is one Memcached instance per client thread.

Overrides:
cleanup in class DataStore
Throws:
DataStoreException

add

public int add(java.lang.String key,
               java.lang.Object value)
Adds a keys value in the database if the key doesn't already exist

Specified by:
add in class Memcached
Parameters:
key - The key to add to the database
value - The Object that will be the value of the key
Returns:
Zero on success, a non-zero error code on error

append

public int append(java.lang.String key,
                  long cas,
                  java.lang.Object value)
Appends a value to a keys current value

Specified by:
append in class Memcached
Parameters:
key - The key who's value will be appended.
The - unique cas value to do the append with
value - The Object to append to the end of the keys current value
Returns:
Zero on success, a non-zero error code on error

cas

public int cas(java.lang.String key,
               long cas,
               java.lang.Object value)
Stores a new value if the operation has the correct cas value

Specified by:
cas in class Memcached
Parameters:
key - The key whose value will be replace in the database
cas - The unique cas value to do the operation with
value - The Object to replace the keys old value with.
Returns:
Zero on success, a non-zero error code on error

decr

public int decr(java.lang.String key,
                java.lang.Object value)
Decrement a keys value in the database

Specified by:
decr in class Memcached
Parameters:
key - The key whose value will be decremented
value - The Object that the key should contain after decrementing
Returns:
Zero on success, a non-zero error code on error

delete

public int delete(java.lang.String key)
Delete a key from the database

Specified by:
delete in class Memcached
Parameters:
key - The key to delete
Returns:
Zero on success, a non-zero error code on error

incr

public int incr(java.lang.String key,
                java.lang.Object value)
Increment a keys value in the database

Specified by:
incr in class Memcached
Parameters:
key - The key whose value will be incremented
value - The Object that the key should contain after incrementing
Returns:
Zero on success, a non-zero error code on error

get

public int get(java.lang.String key,
               java.lang.Object value)
Get a key's value from the database.

Specified by:
get in class Memcached
Parameters:
key - The key to get a value for.
value - The Object that the key should contain
Returns:
Zero on success, a non-zero error code on error

gets

public long gets(java.lang.String key)
Gets a unique cas value for a key.

Specified by:
gets in class Memcached
Parameters:
key - The key to get a cas value for
Returns:
The cas value on success, a non-zero error code on error

prepend

public int prepend(java.lang.String key,
                   long cas,
                   java.lang.Object value)
Prepends a value to a keys current value

Specified by:
prepend in class Memcached
Parameters:
key - The key who's value will be prepended.
The - unique cas value to do the prepend with
value - The Object to prepend to the front of the keys current value
Returns:
Zero on success, a non-zero error code on error

replace

public int replace(java.lang.String key,
                   java.lang.Object value)
Replaces the value of a key already in the database. If a key doesn't exist this operation fails.

Specified by:
replace in class Memcached
Parameters:
key - The key who's value will be replaced.
value - The Object that will replace the old key value.
Returns:
Zero on success, a non-zero error code on error

set

public int set(java.lang.String key,
               java.lang.Object value)
Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified record key.

Specified by:
set in class Memcached
Parameters:
key - The record key of the record to set.
value - The Object to use as the keys value
Returns:
Zero on success, a non-zero error code on error