Class/Object

com.twitter.finagle.memcached

MockClient

Related Docs: object MockClient | package memcached

Permalink

class MockClient extends Client

Map-based mock client for testing

Note

this class now respects expiry times. If you want the old expiry-ignoring behavior, use MockClient.ignoresTtl()

Linear Supertypes
Client, BaseClient[Buf], Closable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MockClient
  2. Client
  3. BaseClient
  4. Closable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new MockClient()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ++=(kvs: TraversableOnce[(String, Cached)]): MockClient

    Permalink

    convenience method for adding several values directly to the underlying map

  4. def +=(kv: (String, Cached)): MockClient

    Permalink

    convenience method for adding a value directly to the underlying map

  5. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  6. def _get(keys: Iterable[String]): GetResult

    Permalink
    Attributes
    protected
  7. def active: Map[String, Cached]

    Permalink

    Returns an immutable copy of the current cache with expired elements filtered out

  8. def adapt[T](bijection: Bijection[Buf, T]): BaseClient[T]

    Permalink
    Definition Classes
    Client
  9. def add(key: String, flags: Int, expiry: Time, value: Buf): Future[Boolean]

    Permalink

    Store a key but only if it doesn't already exist on the server.

    Store a key but only if it doesn't already exist on the server.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    returns

    true if stored, false if not stored

    Definition Classes
    MockClientBaseClient
  10. def add(key: String, value: Buf): Future[Boolean]

    Permalink

    Store a key but only if it doesn't already exist on the server.

    Store a key but only if it doesn't already exist on the server.

    Neither flags nor expiry are supplied.

    returns

    true if stored, false if not stored

    Definition Classes
    BaseClient
  11. def append(key: String, flags: Int, expiry: Time, value: Buf): Future[Boolean]

    Permalink

    Append bytes to the end of an existing key.

    Append bytes to the end of an existing key. If the key doesn't exist, the operation has no effect.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    returns

    true if stored, false if not stored

    Definition Classes
    MockClientBaseClient
  12. def append(key: String, value: Buf): Future[Boolean]

    Permalink

    Append a set of bytes to the end of an existing key.

    Append a set of bytes to the end of an existing key. If the key doesn't exist, the operation has no effect.

    returns

    true if stored, false if not stored

    Definition Classes
    BaseClient
  13. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  14. def bufferToType(v: Buf): Buf

    Permalink

    Deserialize from the bytes in a Buf into the client's type, T.

    Deserialize from the bytes in a Buf into the client's type, T.

    Definition Classes
    ClientBaseClient
  15. def checkAndSet(key: String, flags: Int, expiry: Time, value: Buf, casUnique: Buf): Future[CasResult]

    Permalink

    Perform a CAS operation on the key, only if the value has not changed since the value was last retrieved, and casUnique extracted from a gets command.

    Perform a CAS operation on the key, only if the value has not changed since the value was last retrieved, and casUnique extracted from a gets command. We treat the "cas unique" token opaquely, but in reality it is a string-encoded u64.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    returns

    Stored if the operation was successful, Exists if the operation failed because someone else had changed the value, or NotFound if the key was not found in the cache.

    Definition Classes
    MockClientBaseClient
    See also

    gets and getsResult for retreiving the cas token.

  16. def checkAndSet(key: String, value: Buf, casUnique: Buf): Future[CasResult]

    Permalink

    Perform a CAS operation on the key, only if the value has not changed since the value was last retrieved.

    Perform a CAS operation on the key, only if the value has not changed since the value was last retrieved. This is enforced by passing a casUnique token extracted from a gets command. If the casUnique token matches the one on the server, the value is replaced. We treat the "cas unique" token opaquely, but in reality it is a string-encoded u64.

    Neither flags nor expiry are supplied.

    returns

    Stored if the operation was successful, Exists if the operation failed because someone else had changed the value, or NotFound if the key was not found in the cache.

    Definition Classes
    BaseClient
    See also

    gets and getsResult for retreiving the cas token.

  17. def clear(): Unit

    Permalink

    clear underlying cache: the underlying Map will be empty

  18. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. def close(deadline: Time): Future[Unit]

    Permalink

    Close the underlying resources.

    Close the underlying resources.

    Definition Classes
    MockClientBaseClient → Closable
  20. def close(after: Duration): Future[Unit]

    Permalink
    Definition Classes
    Closable
  21. final def close(): Future[Unit]

    Permalink
    Definition Classes
    Closable
  22. def contents: Map[String, Buf]

    Permalink

    Returns an immutable copy of the current cache.

    Returns an immutable copy of the current cache. API compatible with MockClient

    Note

    The returned Map will contain expired items for backwards compatibility with the old API. To get a Map with them filtered out, use MockClient.active

  23. def decr(key: String, delta: Long): Future[Option[Long]]

    Permalink

    Decrement the key by n.

    Decrement the key by n.

    Interprets the stored value for key as a Long if it is parseable as a decimal representation of a 64-bit unsigned integer.

    This operation has no effect if there is no value there already.

    Definition Classes
    MockClientBaseClient
  24. def decr(key: String): Future[Option[Long]]

    Permalink

    Decrement the key by 1.

    Decrement the key by 1.

    Interprets the stored value for key as a Long if it is parseable as a decimal representation of a 64-bit unsigned integer.

    This operation has no effect if there is no value there already.

    Definition Classes
    BaseClient
  25. def delete(key: String): Future[Boolean]

    Permalink

    Remove a key.

    Remove a key.

    returns

    true if deleted, false if not found

    Definition Classes
    MockClientBaseClient
  26. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  27. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  28. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. def get(keys: Iterable[String]): Future[Map[String, Buf]]

    Permalink

    Get a set of keys from the server.

    Get a set of keys from the server.

    returns

    a Map[String, T] of all of the keys that the server had.

    Definition Classes
    BaseClient
    See also

    gets if you need a "cas unique" token.

  30. def get(key: String): Future[Option[Buf]]

    Permalink

    Get a key from the server.

    Get a key from the server.

    returns

    None if there is no value stored for key.

    Definition Classes
    BaseClient
    See also

    gets if you need a "cas unique" token.

  31. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  32. def getResult(keys: Iterable[String]): Future[GetResult]

    Permalink

    Get a set of keys from the server.

    Get a set of keys from the server. Returns a Future[GetResult] that encapsulates hits, misses and failures.

    Definition Classes
    MockClientBaseClient
    See also

    getsResult if you need "cas unique" tokens.

  33. def getWithFlag(keys: Iterable[String]): Future[Map[String, (Buf, Buf)]]

    Permalink

    Get a set of keys from the server, together with their flags

    Get a set of keys from the server, together with their flags

    returns

    a Map[String, (T, Buf)] of all the keys the server had, together with their flags

    Definition Classes
    BaseClient
    See also

    get if you do not need the flags

  34. def getWithFlag(key: String): Future[Option[(Buf, Buf)]]

    Permalink

    Get a key from the server along with its flags

    Get a key from the server along with its flags

    returns

    None if there is no value stored for key.

    Definition Classes
    BaseClient
    See also

    get if you do not need the flags.

  35. def gets(keys: Iterable[String]): Future[Map[String, (Buf, Buf)]]

    Permalink

    Get a set of keys from the server, together with a "cas unique" token.

    Get a set of keys from the server, together with a "cas unique" token. The token is treated opaquely by the memcache client but is in reality a string-encoded u64.

    returns

    a Map[String, (T, Buf)] of all the keys the server had, together with their "cas unique" token

    Definition Classes
    BaseClient
    See also

    checkAndSet for using the token.

    get if you do not need a "cas unique" token.

  36. def gets(key: String): Future[Option[(Buf, Buf)]]

    Permalink

    Get a key from the server along with a "cas unique" token.

    Get a key from the server along with a "cas unique" token. The token is treated opaquely by the memcache client but is in reality a string-encoded u64.

    returns

    None if there is no value stored for key.

    Definition Classes
    BaseClient
    See also

    checkAndSet for using the token.

    get if you do not need a "cas unique" token.

  37. def getsResult(keys: Iterable[String]): Future[GetsResult]

    Permalink

    Get a set of keys from the server.

    Get a set of keys from the server. Returns a Future[GetsResult] that encapsulates hits, misses and failures. This variant includes the casToken from memcached.

    Definition Classes
    MockClientBaseClient
    See also

    checkAndSet for using the token.

    getResult if you do not need "cas unique" tokens.

  38. def getsWithFlag(keys: Iterable[String]): Future[Map[String, (Buf, Buf, Buf)]]

    Permalink

    Get a set of keys from the server, together with a "cas unique" token and flags.

    Get a set of keys from the server, together with a "cas unique" token and flags. The token is treated opaquely by the memcache client but is in reality a string-encoded u64.

    returns

    a Map[String, (T, Buf, Buf)] of all the keys the server had, together with ther "cas unique" token and flags

    Definition Classes
    BaseClient
    See also

    checkAndSet for using the token.

    getWithFlag if you do not need the token.

    gets if you do not need the flag.

    get if you do not need the token or the flags.

  39. def getsWithFlag(key: String): Future[Option[(Buf, Buf, Buf)]]

    Permalink

    Get a key from the server along with its flags and a "cas unique" token.

    Get a key from the server along with its flags and a "cas unique" token.

    returns

    None if there is no value stored for key.

    Definition Classes
    BaseClient
    See also

    getWithFlag if you do not need the token.

    gets if you do not need the flags.

    get if you do not need the flags or the token.

  40. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  41. def incr(key: String, delta: Long): Future[Option[Long]]

    Permalink

    Increment the key by delta.

    Increment the key by delta.

    Interprets the stored value for key as a Long if it is parseable as a decimal representation of a 64-bit unsigned integer.

    This operation has no effect if there is no value there already.

    Definition Classes
    MockClientBaseClient
  42. def incr(key: String): Future[Option[Long]]

    Permalink

    Increment the key by 1.

    Increment the key by 1.

    Interprets the stored value for key as a Long if it is parseable as a decimal representation of a 64-bit unsigned integer.

    This operation has no effect if there is no value there already.

    Definition Classes
    BaseClient
  43. def isEmpty: Boolean

    Permalink
  44. def isExpired(t: Time): Boolean

    Permalink
    Attributes
    protected
  45. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  46. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  47. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  48. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  49. def prepend(key: String, flags: Int, expiry: Time, value: Buf): Future[Boolean]

    Permalink

    Prepend bytes to the beginning of an existing key.

    Prepend bytes to the beginning of an existing key. If the key doesn't exist, the operation has no effect.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    returns

    true if stored, false if not stored

    Definition Classes
    MockClientBaseClient
  50. def prepend(key: String, value: Buf): Future[Boolean]

    Permalink

    Prepend a set of bytes to the beginning of an existing key.

    Prepend a set of bytes to the beginning of an existing key. If the key doesn't exist, the operation has no effect.

    Neither flags nor expiry are supplied.

    returns

    true if stored, false if not stored

    Definition Classes
    BaseClient
  51. def quit(): Future[Unit]

    Permalink

    Send a quit command to the server.

    Send a quit command to the server. Alternative to release, for protocol compatibility.

    Definition Classes
    BaseClient
  52. def replace(key: String, flags: Int, expiry: Time, value: Buf): Future[Boolean]

    Permalink

    Replace bytes on an existing key.

    Replace bytes on an existing key. If the key doesn't exist, the operation has no effect.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    returns

    true if stored, false if not stored

    Definition Classes
    MockClientBaseClient
  53. def replace(key: String, value: Buf): Future[Boolean]

    Permalink

    Replace an item if it exists.

    Replace an item if it exists. If it doesn't exist, the operation has no effect.

    Neither flags nor expiry are supplied.

    returns

    true if stored, false if not stored

    Definition Classes
    BaseClient
  54. def set(key: String, flags: Int, expiry: Time, value: Buf): Future[Unit]

    Permalink

    Store a key.

    Store a key. Override an existing value.

    flags is an arbitrary integer that the server stores along with the data and sends back when the item is retrieved. Clients may use this as a bit field to store data-specific information; this field is opaque to the server.

    expiry is the expiration time for entries. If it is Time.epoch, Time.Top, Time.Bottom or Time.Undefined then the item never expires, although it may be deleted from the cache to make room for other items. This is also the case for values where the number of seconds is larger than Long.MaxValue. Otherwise, clients will not be able to retrieve this item after the expiration time arrives (measured on the cache server).

    Definition Classes
    MockClientBaseClient
  55. def set(key: String, value: Buf): Future[Unit]

    Permalink

    Store a key.

    Store a key. Override an existing values.

    Neither flags nor expiry are supplied.

    Definition Classes
    BaseClient
  56. def size: Int

    Permalink
  57. def stats(args: Option[String]): Future[Seq[String]]

    Permalink

    Send a stats command with optional arguments to the server.

    Send a stats command with optional arguments to the server.

    returns

    a sequence of strings, each of which is a line of output

    Definition Classes
    MockClientBaseClient
  58. def stats(): Future[Seq[String]]

    Permalink

    Send a stats command to the server.

    Send a stats command to the server.

    returns

    a sequence of strings, each of which is a line of output

    Definition Classes
    BaseClient
  59. def stats(args: String): Future[Seq[String]]

    Permalink

    Send a stats command with the given args to the server.

    Send a stats command with the given args to the server.

    returns

    a sequence of strings, each of which is a line of output

    Definition Classes
    BaseClient
  60. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  61. def toMap: Map[String, Cached]

    Permalink

    Returns an immutable copy of the current cache.

    Returns an immutable copy of the current cache. Values are wrapped in a Cached class, which carries the expiry time and flags given, along with the Buf containing the value.

    Note

    The returned Map *will* contain expired items. To get a Map with them filtered out, use MockClient.active

  62. def toString(): String

    Permalink
    Definition Classes
    MockClient → AnyRef → Any
  63. def update(k: String, v: Buf): Unit

    Permalink
  64. def update(k: String, v: String): Unit

    Permalink
  65. def update(k: String, v: Cached): Unit

    Permalink
  66. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  69. def withBytes: BaseClient[Array[Byte]]

    Permalink

    Adaptor to use Array[Byte] as values

    Adaptor to use Array[Byte] as values

    Definition Classes
    Client
  70. def withStrings: BaseClient[String]

    Permalink

    Adaptor to use String as values

    Adaptor to use String as values

    Definition Classes
    Client

Inherited from Client

Inherited from BaseClient[Buf]

Inherited from Closable

Inherited from AnyRef

Inherited from Any

Ungrouped