Module Expr Str Import alias Import alias ImportFrom alias Assign NameStore Str Assign NameStore ListLoad Str Str Str Str Str Str Str ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body Expr Str Pass decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults NameLoad body Assign AttributeStore NameLoad attr BoolOpOr NameLoad AttributeLoad Call NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Delete SubscriptDel NameLoad Index Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list decorator_list ClassDef bases body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad body Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad body Raise NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareIs NameLoad NameLoad body Raise NameLoad Assign AttributeStore NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad If BoolOpAnd NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Assign NameStore Str Assign NameStore Str Assign NameStore Str decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Return Call NameLoad Call NameLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str TryExcept body Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad handlers ExceptHandler type NameLoad name NameStore body If CompareEq NameLoad AttributeLoad AttributeLoad NameLoad attr attr body Raise NameLoad orelse Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore SubscriptLoad TupleLoad Str Str Slice IfExp NameLoad Num Num If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad If CompareIs NameLoad NameLoad body Return Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad If CompareIs NameLoad NameLoad body Return If CompareNotEq Call NameLoad NameLoad NameLoad AttributeLoad NameLoad attr body If CompareNotEq Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr NameLoad body Return If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict NameLoad AttributeLoad NameLoad attr body Return Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call NameLoad Assign AttributeStore NameLoad attr NameLoad While NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr If CompareIs AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Break orelse If CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore IfExp CompareEq NameLoad AttributeLoad NameLoad attr Str Str If Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Dict NameLoad Str AttributeLoad NameLoad attr NameLoad keyword NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Break orelse Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore SubscriptLoad TupleLoad Str Str Slice IfExp NameLoad Num Num While NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad NameLoad If CompareIs NameLoad NameLoad body Raise NameLoad Assign NameStore CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr If UnaryOpNot BoolOpOr NameLoad CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad Continue Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Continue If Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad IfExp NameLoad Dict Str Str NameLoad NameLoad Dict NameLoad Call NameLoad NameLoad NameLoad body Break Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr keyword NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr For NameStore NameLoad body Expr Yield TupleLoad NameLoad NameLoad Assign NameStore NameLoad Expr Yield TupleLoad NameLoad NameLoad decorator_list ClassDef bases NameLoad body Assign NameStore Str Assign NameStore Str Assign NameStore Str decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list NameLoad decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam NameParam defaults body Assign AttributeStore NameLoad attr AttributeLoad Call NameLoad attr Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad GeneratorExp TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad comprehension TupleStore NameStore NameStore NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Delete SubscriptDel NameLoad Index Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list Assign NameStore Str FunctionDef arguments args NameParam defaults body Expr Str Return BinOpAdd AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign TupleStore NameStore NameStore TupleLoad NameLoad NameLoad If BoolOpAnd CompareEq Call NameLoad NameLoad NameLoad Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Call NameLoad AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad name NameStore body If CompareEq NameLoad NameLoad body Raise NameLoad orelse Assign NameStore NameLoad Return TupleLoad NameLoad NameLoad decorator_list NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str NameLoad If CompareEq NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad Str NameLoad Assert CompareNotEq NameLoad NameLoad Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareEq NameLoad NameLoad body Delete SubscriptDel NameLoad Index NameLoad orelse Assign SubscriptStore NameLoad Index NameLoad NameLoad Return NameLoad decorator_list ClassDef bases NameLoad body Pass decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr TryExcept body If CompareNotEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise NameLoad For TupleStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr body Assign NameStore NameLoad While NameLoad body If Call NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad body Break Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareEq NameLoad NameLoad body Break orelse Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If NameLoad body Assign NameStore NameLoad Continue orelse If NameLoad body Expr Call NameLoad NameLoad NameLoad orelse Assign NameStore AttributeLoad NameLoad attr Raise NameLoad Assign NameStore AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body Pass If CompareIsNot NameLoad NameLoad body If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad Dict Str NameLoad keyword NameLoad body TryExcept body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad body If NameLoad body Raise orelse Return Assign NameStore CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr For TupleStore TupleStore NameStore NameStore NameStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareEq NameLoad NameLoad body If BoolOpAnd Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad IfExp NameLoad NameLoad NameLoad NameLoad body If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Return Call NameLoad NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore NameLoad While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore IfExp CompareIs NameLoad NameLoad NameLoad SubscriptLoad Call NameLoad NameLoad Index NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If NameLoad body Assign NameStore NameLoad Continue orelse If NameLoad body Expr Call NameLoad NameLoad NameLoad orelse Return Call NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Import alias Import alias Expr Call AttributeLoad NameLoad attr keyword Dict Str NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A Concurrent, distributed data structures on memcache.

Main items in this module:

   deque:  a lock-free, double-ended queue
   mcas, mcas_get:  lock-free, multi-entry compare and set
 N/A copy N/A threading uuid uuid4 N/A __author__ John Belmonte <john@neggie.net> N/A __all__ N/A deque mcas mcas_get Entry Error NodeNotFoundError SetError Error N/A Exception N/A N/A Base class for exceptions in this module. N/A N/A NodeNotFoundError N/A Error N/A N/A Node not found in storage-- indicates a corrupted collection. N/A N/A SetError N/A Error N/A N/A Memcache set operation failed-- indicates server unavailable (or full,
  if evicitons are disabled). N/A N/A AddError N/A Error N/A N/A Memcache add operation failed-- indicates server unavailable (or full,
  if evicitons are disabled), or a race creating an entry. N/A N/A _Node N/A object N/A __init__ N/A N/A self uuid N/A None N/A N/A N/A self uuid N/A uuid N/A N/A uuid4 hex N/A N/A self value None N/A N/A self next_uuid None N/A N/A self prev_uuid None N/A __getstate__ N/A N/A self N/A N/A N/A state N/A N/A N/A self __dict__ copy N/A N/A state N/A uuid N/A state N/A __eq__ N/A N/A self other N/A N/A N/A N/A N/A self __dict__ N/A other __dict__ N/A __ne__ N/A N/A self other N/A N/A N/A N/A N/A self __dict__ N/A other __dict__ N/A N/A _DequeClient N/A N/A N/A Encapsulates all memcache access. __init__ N/A N/A self memcache_client N/A N/A N/A N/A self mc memcache_client N/A SaveNode N/A N/A self node N/A N/A N/A N/A N/A N/A N/A self mc set N/A node uuid node N/A N/A SetError N/A AddNode N/A N/A self node N/A N/A N/A N/A N/A N/A N/A self mc add N/A node uuid node N/A N/A AddError N/A DeleteNode N/A N/A self node N/A N/A N/A N/A N/A N/A self mc delete N/A node uuid N/A LoadNodeFromUuid N/A N/A self uuid N/A N/A N/A node N/A N/A N/A self mc gets uuid N/A N/A node None N/A N/A NodeNotFoundError N/A N/A node uuid uuid N/A node N/A Cas N/A N/A self node attributes update_on_success N/A False N/A N/A Write node to memcache using CAS.

    Args:
      node: A _Node instance.
      attributes: A dictionary of node attributes to update.
      update_on_success: True if attribute changes should be applied to input
          node on successful CAS.

    Returns:
      True on successful CAS.
     N/A new_node N/A N/A copy copy node N/A N/A new_node uuid N/A node uuid N/A N/A N/A N/A new_node __dict__ update attributes N/A result N/A N/A N/A self mc cas N/A node uuid new_node N/A N/A result update_on_success N/A N/A N/A N/A N/A node __dict__ update attributes N/A result N/A N/A _Status N/A object N/A N/A STABLE STABLE N/A R_PUSH R_PUSH N/A L_PUSH L_PUSH N/A deque N/A object N/A N/A Lock-free deque on memcache.

  Each node of the queue is held in a separate memcache entry.  Nodes are
  deleted upon pop (as opposed to being re-used).  All operations
  on the queue are serialized (i.e. head/tail access is not disjoint).

  This interface is modeled after collections.deque.  Only append and pop
  operations are supported (no length, iteration, clear, etc.).

  Synopsis:

    >>> from memcache_collections import deque
    >>> mc = memcache.Client(['127.0.0.1:11211'], cache_cas=True)
    >>> d = deque.create(mc, 'my_deque')
    >>> d.appendleft(5)
    >>> d.appendleft('hello')

  then from some other process or machine:

    >>> d = deque.bind(mc, 'my_deque')
    >>> d.pop()
    5
    >>> d.pop()
    'hello'
    >>> d.pop()
    Traceback (most recent call last):
        ...
    IndexError

  This class is thread safe assuming that the given memcache client is.


  CAVEATS

  Low durability - the collection will be corrupted on loss of any
  underlying memcache entry (e.g. from evictions or memcache server
  restart).  The corruption state is detectable and reported by the
  client library.

  Due to the eviction issue, mixing these collections with other classes
  of data in the same memcache instance is problematic (i.e. less
  important items may corrupt the data structure).  You probably
  want to dedicate a memcache instance to hold fragile data such as these
  collections and manage it so as to not reach the full state.  The
  memcached server has an option to disable evictions (-M) which can help
  in ensuring the system is healthy.

  Regarding CAS ID management, the Python memcache API unfortunately
  requires client implementations to hold on to CAS ID's indefinitely.
  This is problematic for our use case since the number of memcache
  entries using CAS is unbounded.  As a consequence, deque users are
  responsible for managing CAS ID lifetime, for example by calling
  reset_cas() on the given memcache client at appropriate times, and
  perhaps dedicating a memcache client instance soley for use by our
  collections.  As far as this API is concerned, it's safe to call
  reset_cas() outside of any public method.


  PERFORMANCE NOTES

  Very roughly I've seen the deque reach contention limits at ~400
  combined read+write operations/s on a slow laptop and ~1,200 ops/s on
  a decent workstation given small values and the pure Python memcached
  client talking to memcached on the same machine via TCP.

  In applications where exact item ordering is not important, higher
  operation rates can be achieved by application-level sharding to
  multiple deque instances.


  IMPLEMENTATION NOTES

  Based on "CAS-Based Lock-Free Algorithm for Shared Deques",
  Maged M. Michael, 2003,
  http://www.cs.bgu.ac.il/~mpam092/wiki.files/michael-dequeues.pdf.

  This was the simplest (correct) lock-free algorithm I could find, which
  not surprisingly doesn't allow disjoint access of each queue end.
  Algorithms supporting disjoint access redily exist, such as presented
  in "Lock-Free and Practical Doubly Linked List-Based Deques Using
  Single-Word Compare-and-Swap", Sundell and Tsigas, 2005.  This would
  effectively halve the contention rate when the deque is used as a FIFO,
  but at a considerable complexity cost.

  I'm aware of simple lock-free queue and list implementations which
  attempt to employ memcache's atomic increment operation to generate
  node addresses. However they all seem to suffer from unhandled race
  conditions and it's not obvious to me there is a fix.  Increment can be
  used as a locking mechanism, however.  A locking approach may be more
  fair to clients relative to CAS over a network, but introduces its own
  complexities in needing to address client deaths, deadlocks, etc.

  The implementation assumes that memcache CAS does not suffer from the
  "A->B->A" problem (valid at least for memcached).
   __init__ N/A N/A self deque_client uuid N/A N/A N/A For internal use only.  Use create() or bind(). N/A N/A self client deque_client N/A N/A self anchor_uuid uuid N/A N/A self thread_local N/A N/A threading local N/A N/A N/A self thread_local last_missing_node None N/A create N/A N/A cls memcache_client name N/A None N/A N/A Create a new collection in memcache.

    If optional name is given, it will be used verbatim as the key for the
    root entry of the collection.

    Raises AddError if the named collection already exists.
     N/A client N/A _DequeClient memcache_client N/A anchor N/A _Node name N/A N/A anchor value N/A _Status STABLE N/A N/A N/A client AddNode anchor N/A N/A cls client N/A anchor uuid N/A classmethod bind N/A N/A cls memcache_client name N/A N/A N/A Bind to an existing collection in memcache. N/A N/A cls N/A _DequeClient memcache_client name N/A classmethod name N/A N/A self N/A N/A N/A Returns the unique name of this queue instance. N/A N/A self anchor_uuid N/A property _SafeLoadNodeFromUuid N/A N/A self uuid N/A N/A N/A Returns node if it exists, else None.

    Raises NodeNotFoundError if a node is missing twice consecutively, which
    implies corruption of the deque.
     N/A N/A N/A N/A N/A N/A self client LoadNodeFromUuid uuid N/A N/A N/A NodeNotFoundError N/A e N/A N/A N/A uuid N/A N/A self thread_local last_missing_node N/A N/A e N/A N/A N/A N/A self thread_local last_missing_node uuid N/A _Stabilize N/A N/A self anchor last N/A None N/A N/A Make deque coherent if necessary and transition to stable state.

    An incoherent deque will require that the penultimate node be adjusted
    to point to the last node.

    We silently cede upon any detected race, as that provably implies the
    deque reached the stable state by another process.
     N/A is_right N/A N/A anchor value N/A _Status R_PUSH N/A N/A link reverse_link N/A N/A next_uuid prev_uuid N/A N/A is_right 1 -1 N/A N/A last None N/A N/A last N/A N/A self _SafeLoadNodeFromUuid N/A getattr anchor link N/A N/A last None N/A N/A N/A penultimate N/A N/A self _SafeLoadNodeFromUuid N/A getattr last reverse_link N/A N/A penultimate None N/A N/A N/A N/A N/A getattr penultimate link N/A last uuid N/A N/A N/A N/A N/A N/A self client LoadNodeFromUuid N/A anchor uuid anchor N/A N/A N/A N/A N/A N/A N/A self client Cas penultimate N/A link N/A last uuid N/A N/A N/A N/A N/A N/A self client Cas anchor N/A value N/A _Status STABLE N/A _PushCommon N/A N/A self value target_status N/A N/A N/A node N/A _Node N/A N/A node value value N/A True N/A N/A anchor N/A N/A N/A self client LoadNodeFromUuid N/A self anchor_uuid N/A N/A N/A anchor next_uuid None N/A N/A N/A N/A N/A self client SaveNode node N/A N/A N/A N/A self client Cas anchor N/A prev_uuid next_uuid N/A node uuid N/A node uuid N/A N/A N/A N/A N/A N/A anchor value N/A _Status STABLE N/A N/A N/A node prev_uuid N/A anchor next_uuid N/A N/A node next_uuid N/A anchor prev_uuid N/A N/A N/A N/A self client SaveNode node N/A link N/A N/A target_status N/A _Status R_PUSH next_uuid prev_uuid N/A N/A N/A N/A self client Cas anchor N/A link value N/A node uuid target_status update_on_success True N/A N/A N/A N/A self _Stabilize anchor node N/A N/A N/A N/A N/A self _Stabilize anchor N/A append N/A N/A self value N/A N/A N/A Add value to the right side of the queue. N/A N/A N/A self _PushCommon value N/A _Status R_PUSH N/A appendleft N/A N/A self value N/A N/A N/A Add value to the left side of the queue. N/A N/A N/A self _PushCommon value N/A _Status L_PUSH N/A _PopCommon N/A N/A self is_right N/A N/A N/A N/A link reverse_link N/A N/A next_uuid prev_uuid N/A N/A is_right 1 -1 N/A True N/A N/A anchor N/A N/A N/A self client LoadNodeFromUuid N/A self anchor_uuid N/A node_uuid N/A getattr anchor link N/A N/A node_uuid None N/A N/A IndexError N/A is_single_item N/A N/A anchor prev_uuid N/A anchor next_uuid N/A N/A N/A is_single_item N/A N/A anchor value N/A _Status STABLE N/A N/A N/A N/A self _Stabilize anchor N/A N/A node N/A N/A self _SafeLoadNodeFromUuid node_uuid N/A N/A node None N/A N/A N/A N/A N/A N/A self client Cas anchor N/A is_single_item N/A prev_uuid next_uuid None None N/A link N/A getattr node reverse_link N/A N/A N/A N/A N/A N/A self client DeleteNode node N/A N/A node value N/A pop N/A N/A self N/A N/A N/A Remove and return an element from the right side of the queue.  If
    no elements are present, raises an IndexError. N/A N/A N/A self _PopCommon is_right True N/A popleft N/A N/A self N/A N/A N/A Remove and return an element from the left side of the queue.  If
    no elements are present, raises an IndexError. N/A N/A N/A self _PopCommon is_right False N/A N/A _last_iter N/A N/A iterable N/A N/A N/A Transforms given iterable to yield (item, is_last) tuples. N/A it N/A iter iterable N/A last N/A N/A it next N/A val it N/A N/A N/A N/A last False N/A last val N/A N/A N/A last True N/A _McasStatus N/A object N/A N/A UNDECIDED UNDECIDED N/A SUCCESSFUL SUCCESSFUL N/A FAILED FAILED N/A Entry N/A object N/A N/A Represents a memcache entry at a certain point in time. __init__ N/A N/A self key value cas_id N/A N/A N/A N/A self _key key N/A N/A self _value value N/A N/A self _cas_id cas_id N/A key N/A N/A self N/A N/A N/A N/A self _key N/A property value N/A N/A self N/A N/A N/A N/A self _value N/A property cas_id N/A N/A self N/A N/A N/A N/A self _cas_id N/A property N/A _McasRecord N/A object N/A __init__ N/A N/A self mc entries N/A N/A N/A N/A self uuid N/A N/A uuid4 hex N/A N/A self status N/A _McasStatus UNDECIDED N/A N/A self items N/A sorted N/A N/A N/A entry key N/A entry value N/A entry cas_id new_value N/A N/A entry new_value entries N/A __getstate__ N/A N/A self N/A N/A N/A state N/A N/A N/A self __dict__ copy N/A N/A state N/A uuid N/A state N/A __eq__ N/A N/A self other N/A N/A N/A N/A N/A self __dict__ N/A other __dict__ N/A __ne__ N/A N/A self other N/A N/A N/A N/A N/A self __dict__ N/A other __dict__ N/A N/A REF_SENTINEL memcache-collections-mcas-record: make_ref N/A N/A self N/A N/A N/A Return reference to this MCAS record to be stored in memcache. N/A N/A N/A self REF_SENTINEL N/A self uuid N/A deref N/A N/A cls dc value last_missing_value N/A N/A N/A Return MCAS record if given value is a reference, else None.

    If the value is a reference, and the memcache entry for the MCAS
    record cannot be found, then last_missing_value comes into play.
    If value == last_missing_value then surface the NodeNotFoundError
    exception.  Otherwise we supress the exception and return
    is_missing = True.

    Returns: (mcas_record, is_missing)
     N/A N/A mcas_record is_missing N/A None False N/A N/A N/A N/A type value str N/A N/A value startswith N/A cls REF_SENTINEL N/A N/A N/A N/A mcas_record N/A N/A dc LoadNodeFromUuid N/A value N/A N/A len N/A cls REF_SENTINEL N/A N/A N/A NodeNotFoundError N/A e N/A N/A N/A value last_missing_value N/A N/A e N/A N/A is_missing True N/A N/A mcas_record is_missing N/A classmethod N/A _get_cas_ids N/A N/A mc N/A N/A N/A Get implementation-specific CAS ID dictionary. N/A cas_ids N/A getattr mc cas_ids None N/A N/A cas_ids None N/A N/A cas_ids N/A getattr mc _cas_ids None N/A N/A cas_ids None Explicit CAS not supported for memcache client N/A cas_ids N/A _explicit_cas N/A N/A mc key value cas_id N/A N/A N/A Perform CAS given explicit unique ID. N/A cas_ids N/A _get_cas_ids mc N/A original_id N/A N/A cas_ids get key N/A N/A cas_ids N/A key cas_id N/A result N/A N/A mc cas key value N/A N/A original_id None N/A N/A N/A cas_ids N/A key N/A N/A N/A cas_ids N/A key original_id N/A result N/A _ReleaseMcas N/A Exception N/A N/A N/A _mcas_help N/A N/A dc mcas_record is_originator N/A False N/A N/A Attempt to take given MCAS transaction to completed state.

  Args:
    dc: DequeClient helper object
    mcas_record: existing transaction record, must already be loaded for CAS
    is_originator: True if caller originated the MCAS operation

  Returns:  True if transaction reached successful state.  This status is
      returned only in the is_originator case.
   N/A result_status None N/A mcas_ref N/A N/A mcas_record make_ref N/A N/A N/A N/A N/A mcas_record status N/A _McasStatus UNDECIDED N/A N/A _ReleaseMcas N/A N/A key _ cas_id _ N/A mcas_record items N/A N/A last_missing_mcas_ref None N/A True N/A N/A N/A _explicit_cas N/A dc mc key mcas_ref cas_id N/A N/A N/A location N/A N/A N/A dc mc get key N/A N/A location mcas_ref N/A N/A N/A N/A N/A nested_mcas_record is_missing N/A N/A _McasRecord deref dc location last_missing_mcas_ref N/A is_missing N/A N/A last_missing_mcas_ref location N/A N/A N/A nested_mcas_record N/A N/A N/A _mcas_help dc nested_mcas_record N/A N/A result_status N/A _McasStatus FAILED N/A _ReleaseMcas N/A result_status N/A _McasStatus SUCCESSFUL N/A N/A N/A _ReleaseMcas N/A N/A N/A N/A result_status None N/A N/A N/A N/A N/A dc Cas mcas_record N/A status result_status update_on_success True N/A N/A N/A N/A mcas_record N/A N/A dc LoadNodeFromUuid N/A mcas_record uuid N/A N/A N/A NodeNotFoundError N/A N/A is_originator N/A N/A N/A N/A N/A is_success N/A N/A mcas_record status N/A _McasStatus SUCCESSFUL N/A N/A N/A key value _ new_value is_last N/A _last_iter N/A mcas_record items N/A N/A location N/A N/A N/A dc mc gets key N/A N/A location mcas_ref N/A N/A N/A N/A N/A N/A dc mc cas key N/A is_success new_value value is_last N/A N/A is_originator N/A N/A N/A N/A dc DeleteNode mcas_record N/A is_originator N/A N/A is_success N/A mcas N/A N/A mc entries N/A N/A N/A Multi-entry compare-and-set.

  Synopsis:
    >>> from memcache_collections import mcas
    >>> mc = memcache.Client(['127.0.0.1:11211'], cache_cas=True)
    >>> # initialize a doubly-linked list with two elements
    >>> mc.set_multi({
    ...     'foo': {'next': 'bar'},
    ...     'bar': {'prev': 'foo'}})
    []
    >>> # Always use mcas_get to access entries potentially in MCAS
    >>> # operations.  It returns an object representing a memcache entry
    >>> # snapshot.
    >>> foo_entry, bar_entry = mcas_get(mc, 'foo'), mcas_get(mc, 'bar')
    >>> foo_entry.key, foo_entry.value
    ('foo', {'next': 'bar'})
    >>> # atomically insert new node in our doubly linked list via MCAS
    >>> mc.add('baz', {'prev': 'foo', 'next': 'bar'})
    1
    >>> mcas(mc, [
    ...     (foo_entry, {'next': 'baz'}),
    ...     (bar_entry, {'prev': 'baz'})])
    True

  Function is not thread safe due to implicit CAS ID handling of the
  Python API.

  Args:
    mc: memcache client
    entries: iterable of (Entry, new_value) tuples

  Returns: True if MCAS completed successfully.

  The aggregate size of current and new values for all entries must fit
  within the memcache value limit (typically 1 MB).

  Based on "Practical lock-freedom", Keir Fraser, 2004, pp. 30-34.
   N/A dc N/A _DequeClient mc N/A mcas_record N/A _McasRecord mc entries N/A N/A N/A dc AddNode mcas_record N/A N/A N/A N/A dc mc gets N/A mcas_record uuid N/A N/A _mcas_help dc mcas_record is_originator True N/A mcas_get N/A N/A mc key N/A N/A N/A Safely read a memcache entry which may be involved in MCAS operations.

  Function is not thread safe due to implicit CAS ID handling of the
  Python API.

  Args:
    mc: memcache client
    key: memcache entry key

  Returns: Entry object if memcache entry exists, else None
   N/A dc N/A _DequeClient mc N/A last_missing_mcas_ref None N/A True N/A N/A value N/A N/A mc gets key N/A cas_id N/A N/A value None None N/A N/A _get_cas_ids mc N/A key N/A N/A mcas_record is_missing N/A N/A _McasRecord deref dc value last_missing_mcas_ref N/A is_missing N/A N/A last_missing_mcas_ref value N/A N/A N/A mcas_record N/A N/A N/A _mcas_help dc mcas_record N/A N/A N/A Entry key value cas_id N/A test N/A N/A N/A N/A N/A doctest N/A mockcache N/A N/A N/A doctest testmod extraglobs N/A memcache mockcache N/A N/A N/A __name__ __main__ N/A N/A N/A test