net.spy.memcached
Interface OperationFactory

All Known Implementing Classes:
AsciiOperationFactory, BaseOperationFactory, BinaryOperationFactory

public interface OperationFactory

Factory that builds operations for protocol handlers.


Method Summary
 CASOperation cas(StoreType t, String key, long casId, int flags, int exp, byte[] data, OperationCallback cb)
          Create a CAS operation.
 ConcatenationOperation cat(ConcatenationType catType, long casId, String key, byte[] data, OperationCallback cb)
          Get a concatenation operation.
 Collection<Operation> clone(KeyedOperation op)
          Clone an operation.
 DeleteOperation delete(String key, OperationCallback operationCallback)
          Create a deletion operation.
 FlushOperation flush(int delay, OperationCallback operationCallback)
          Create a flush operation.
 GetOperation get(Collection<String> keys, GetOperation.Callback cb)
          Create a get operation.
 GetOperation get(String key, GetOperation.Callback callback)
          Create a get operation.
 GetsOperation gets(String key, GetsOperation.Callback callback)
          Create a gets operation.
 MutatorOperation mutate(Mutator m, String key, int by, long def, int exp, OperationCallback cb)
          Create a mutator operation.
 NoopOperation noop(OperationCallback cb)
          Create a NOOP operation.
 StatsOperation stats(String arg, StatsOperation.Callback cb)
          Get a new StatsOperation.
 StoreOperation store(StoreType storeType, String key, int flags, int exp, byte[] data, OperationCallback cb)
          Create a store operation.
 VersionOperation version(OperationCallback cb)
          Create a new version operation.
 

Method Detail

noop

NoopOperation noop(OperationCallback cb)
Create a NOOP operation.

Parameters:
cb - the operation callback
Returns:
the new NoopOperation

delete

DeleteOperation delete(String key,
                       OperationCallback operationCallback)
Create a deletion operation.

Parameters:
key - the key to delete
operationCallback - the status callback
Returns:
the new DeleteOperation

flush

FlushOperation flush(int delay,
                     OperationCallback operationCallback)
Create a flush operation.

Parameters:
delay - delay until flush.
operationCallback - the status callback
Returns:
the new FlushOperation

get

GetOperation get(String key,
                 GetOperation.Callback callback)
Create a get operation.

Parameters:
key - the key to get
callback - the callback that will contain the results
Returns:
a new GetOperation

gets

GetsOperation gets(String key,
                   GetsOperation.Callback callback)
Create a gets operation.

Parameters:
key - the key to get
callback - the callback that will contain the results
Returns:
a new GetsOperation

get

GetOperation get(Collection<String> keys,
                 GetOperation.Callback cb)
Create a get operation.

Parameters:
keys - the collection of keys to get
cb - the callback that will contain the results
Returns:
a new GetOperation

mutate

MutatorOperation mutate(Mutator m,
                        String key,
                        int by,
                        long def,
                        int exp,
                        OperationCallback cb)
Create a mutator operation.

Parameters:
m - the mutator type
key - the mutatee key
by - the amount to increment or decrement
def - the default value
exp - expiration in case we need to default (0 if no default)
cb - the status callback
Returns:
the new mutator operation

stats

StatsOperation stats(String arg,
                     StatsOperation.Callback cb)
Get a new StatsOperation.

Parameters:
arg - the stat parameter (see protocol docs)
cb - the stats callback
Returns:
the new StatsOperation

store

StoreOperation store(StoreType storeType,
                     String key,
                     int flags,
                     int exp,
                     byte[] data,
                     OperationCallback cb)
Create a store operation.

Parameters:
storeType - the type of store operation
key - the key to store
flags - the storage flags
exp - the expiration time
data - the data
cb - the status callback
Returns:
the new store operation

cat

ConcatenationOperation cat(ConcatenationType catType,
                           long casId,
                           String key,
                           byte[] data,
                           OperationCallback cb)
Get a concatenation operation.

Parameters:
catType - the type of concatenation to perform.
key - the key
casId - the CAS value for an atomic compare-and-cat
data - the data to store
cb - a callback for reporting the status
Returns:
thew new ConcatenationOperation

cas

CASOperation cas(StoreType t,
                 String key,
                 long casId,
                 int flags,
                 int exp,
                 byte[] data,
                 OperationCallback cb)
Create a CAS operation.

Parameters:
key - the key to store
casId - the CAS identifier value (from a gets operation)
flags - the storage flags
exp - the expiration time
data - the data
cb - the status callback
Returns:
the new store operation

version

VersionOperation version(OperationCallback cb)
Create a new version operation.


clone

Collection<Operation> clone(KeyedOperation op)
Clone an operation.

This is used for requeueing operations after a server is found to be down.

Note that it returns more than one operation because a multi-get could potentially need to be played against a large number of underlying servers. In this case, there's a separate operation for each, and callback façade to reassemble them. It is left up to the operation pipeline to perform whatever optimization is required to turn these back into multi-gets.

Parameters:
op - the operation to clone
Returns:
a new operation for each key in the original operation