
    KiY                        d dl mZmZ d dlmZmZmZmZ e G d de             Ze G d de             Z	e G d de             Z
e G d	 d
e             Ze G d de             Ze G d de             Z G d dee      Zy)    )MappingSequence)AnyProtocolSupportsFloatruntime_checkablec                      e Zd ZdZdddededz  deeef   dz  fdZdddededz  deeeef   dz  e	dz  f   fdZ
ddd	ded
eeef   dedz  dedz  ddf
dZdddededz  defdZdddee   dedz  deeeef   dz     fdZdddee   dedz  deeeeef   dz  e	dz  f      fdZddd	dee   deeeef      dedz  dedz  ddf
dZdddee   dedz  defdZy)AsyncKeyValueProtocolab  A subset of KV operations: get/put/delete and TTL variants, including bulk calls.

    This protocol defines the minimal contract for key-value store implementations. All methods may
    raise exceptions on connection failures, validation errors, or other operational issues.

    Implementations should handle backend-specific errors appropriately.
    N)
collectionkeyr   returnc                   K   yw)ay  Retrieve a value by key from the specified collection.

        Args:
            key: The key to retrieve the value from.
            collection: The collection to retrieve the value from. If no collection is provided, it will use the default collection.

        Returns:
            The value associated with the key. If the key is not found, None will be returned.
        N selfr   r   s      m/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/key_value/aio/protocols/key_value.pygetzAsyncKeyValueProtocol.get   s      	   c                   K   yw)a  Retrieve the value and TTL information for a key-value pair from the specified collection.

        Args:
            key: The key to retrieve the TTL information from.
            collection: The collection to retrieve the TTL information from. If no collection is provided,
                        it will use the default collection.

        Returns:
            The value and TTL information for the key. If the key is not found, (None, None) will be returned.
        Nr   r   s      r   ttlzAsyncKeyValueProtocol.ttl          	r   )r   r   valuer   c                   K   yw)a  Store a key-value pair in the specified collection with optional TTL.

        Args:
            key: The key to store the value in.
            value: The value to store.
            collection: The collection to store the value in. If no collection is provided, it will use the default collection.
            ttl: The optional time-to-live (expiry duration) in seconds for the key-value pair. Defaults to no TTL. Note: The
                backend store will convert the provided format to its own internal format.
        Nr   )r   r   r   r   r   s        r   putzAsyncKeyValueProtocol.put-         	r   c                   K   yw)a_  Delete a key-value pair from the specified collection.

        Args:
            key: The key to delete the value from.
            collection: The collection to delete the value from. If no collection is provided, it will use the default collection.

        Returns:
            True if the key was deleted, False if the key did not exist.
        Nr   r   s      r   deletezAsyncKeyValueProtocol.delete9   r   r   keysc                   K   yw)a  Retrieve multiple values by key from the specified collection.

        Args:
            keys: The keys to retrieve the values from.
            collection: The collection to retrieve keys from. If no collection is provided, it will use the default collection.

        Returns:
            A list of values for the keys. Each value is either a dict or None if the key is not found.
        Nr   r   r   r   s      r   get_manyzAsyncKeyValueProtocol.get_manyE   r   r   c                   K   yw)a  Retrieve multiple values and TTL information by key from the specified collection.

        Args:
            keys: The keys to retrieve the values and TTL information from.
            collection: The collection to retrieve keys from. If no collection is provided, it will use the default collection.

        Returns:
            A list of tuples containing (value, ttl) for each key. Each tuple contains either (dict, float) or (None, None) if the
            key is not found.
        Nr   r    s      r   ttl_manyzAsyncKeyValueProtocol.ttl_manyQ   r   r   valuesc                   K   yw)aL  Store multiple key-value pairs in the specified collection.

        Args:
            keys: The keys to store the values in.
            values: The values to store.
            collection: The collection to store keys in. If no collection is provided, it will use the default collection.
            ttl: The optional time-to-live (expiry duration) in seconds for all key-value pairs. The same TTL will be applied
                to all items in the batch. Defaults to no TTL. Note: The backend store will convert the provided format to
                its own internal format.
        Nr   )r   r   r$   r   r   s        r   put_manyzAsyncKeyValueProtocol.put_many^   s     $ 	r   c                   K   yw)aD  Delete multiple key-value pairs from the specified collection.

        Args:
            keys: The keys to delete the values from.
            collection: The collection to delete keys from. If no collection is provided, it will use the default collection.

        Returns:
            The number of keys deleted.
        Nr   r    s      r   delete_manyz!AsyncKeyValueProtocol.delete_manyr   r   r   )__name__
__module____qualname____doc__strdictr   r   tuplefloatr   r   r   r   boolr   r   listr!   r#   r&   intr(   r       r   r
   r
      s!    "&	 $J	
 
c3h$	" ?C S t uTRUWZRZ^^bMbdilpdpMpGq  Y]z~ 
S 
c): 
3QU: 
cpswcw 
  DH 
 BF 
 
C$J 
$ 
 OS 
8C= 
t 
W[\`adfiai\jmq\qWr 
 OS 8C= t W[\abfgjlogobpswbwy~  BF  zF  cF  ]G  XH $ "&$(sm c*+
 $J T! 
( RV 
hsm 
C$J 
Z] 
r4   r
   c                       e Zd ZddZy)AsyncCullProtocolNc                    K   yw)zSCull the store.

        This will remove all expired keys from the store.
        Nr   r   s    r   cullzAsyncCullProtocol.cull        
 	r   )r   N)r)   r*   r+   r9   r   r4   r   r6   r6      s    r4   r6   c            	       >    e Zd ZdZddddedz  dedz  dee   fdZy)	AsyncEnumerateKeysProtocolz3Protocol segment to enumerate keys in a collection.Nlimitr   r>   r   c                   K   yw)a4  List all keys in the specified collection.

        Args:
            collection: The collection to list the keys from. If no collection is provided, it will use the default collection.
            limit: The maximum number of keys to list. The behavior when no limit is provided is store-dependent.
        Nr   )r   r   r>   s      r   r   zAsyncEnumerateKeysProtocol.keys   s      	r   )N)r)   r*   r+   r,   r-   r3   r2   r   r   r4   r   r<   r<      s5    =t S4Z #* X\]`Xa r4   r<   c                   .    e Zd Zdddedz  dee   fdZy)!AsyncEnumerateCollectionsProtocolNr=   r>   r   c                   K   yw)zList all available collection names (may include empty collections).

        Args:
            limit: The maximum number of collections to list. The behavior when no limit is provided is store-dependent.
        Nr   )r   r>   s     r   collectionsz-AsyncEnumerateCollectionsProtocol.collections         	r   )r)   r*   r+   r3   r2   r-   rC   r   r4   r   rA   rA      s     7; #* S	 r4   rA   c                       e Zd ZdZdefdZy)AsyncDestroyStoreProtocolz1Protocol segment for store-destruction semantics.r   c                    K   yw)z`Destroy the keystore.

        This will clear all collections and keys from the store.
        Nr   r8   s    r   destroyz!AsyncDestroyStoreProtocol.destroy   r:   r   N)r)   r*   r+   r,   r1   rH   r   r4   r   rF   rF      s    ;t r4   rF   c                       e Zd ZdedefdZy)AsyncDestroyCollectionProtocolr   r   c                    K   yw)zlDestroy the specified collection.

        Args:
            collection: The collection to destroy.
        Nr   )r   r   s     r   destroy_collectionz1AsyncDestroyCollectionProtocol.destroy_collection   rD   r   N)r)   r*   r+   r-   r1   rL   r   r4   r   rJ   rJ      s    3 4 r4   rJ   c                       e Zd ZdZy)AsyncKeyValuezA protocol for key-value store operations.

    Includes basic operations: get, put, delete, ttl
    Includes bulk operations: get_many, put_many, delete_many, ttl_many.
    N)r)   r*   r+   r,   r   r4   r   rN   rN      s    r4   rN   N)collections.abcr   r   typingr   r   r   r   r
   r6   r<   rA   rF   rJ   rN   r   r4   r   <module>rQ      s    - B B vH v vr    
 
 
       X  )8 r4   