o
    i                     @   s   d dl mZ d dlmZmZmZmZ eG dd deZeG dd deZeG dd deZ	eG d	d
 d
eZ
eG dd deZeG dd deZG dd deeZdS )    )Sequence)AnyProtocolSupportsFloatruntime_checkablec                   @   s  e Zd ZdZdddededB deeef dB fddZdddededB deeeef dB e	dB f fd	d
Z
ddddedeeef dedB dedB ddf
ddZdddededB defddZdddee dedB deeeef dB  fddZdddee dedB deeeeef dB e	dB f  fddZddddee deeeef  dedB deedB  dB ddf
ddZdddee dedB defddZdS )AsyncKeyValueProtocolzQA subset of KV operations: get/put/delete and TTL variants, including bulk calls.N)
collectionkeyr   returnc                      dS )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   r   r   g/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/key_value/aio/protocols/key_value.pyget	   s   zAsyncKeyValueProtocol.getc                   r   )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   r   r   r   ttl      zAsyncKeyValueProtocol.ttl)r   r   valuer   c                   r   )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   r   r   r   put'      
zAsyncKeyValueProtocol.putc                   r   )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.
        Nr   r   r   r   r   delete3      zAsyncKeyValueProtocol.deletekeysc                   r   )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   r   r   r   get_many<   r   zAsyncKeyValueProtocol.get_manyc                   r   )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   r   r   r   ttl_manyH   r   zAsyncKeyValueProtocol.ttl_manyvaluesc                   r   )a  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 the key-value pairs. Defaults to no TTL. Note: The
                backend store will convert the provided format to its own internal format.
        Nr   )r   r   r   r   r   r   r   r   put_manyU   s   zAsyncKeyValueProtocol.put_manyc                   r   )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   r   r   r   delete_manyh   r   z!AsyncKeyValueProtocol.delete_many)__name__
__module____qualname____doc__strdictr   r   tuplefloatr   r   r   boolr   listr   r   r   r   intr   r   r   r   r   r      s:    
86 4	@
(r   c                   @   s   e Zd ZdddZdS )AsyncCullProtocolr
   Nc                    r   )zSCull the store.

        This will remove all expired keys from the store.
        Nr   r   r   r   r   cullw      zAsyncCullProtocol.cull)r
   N)r   r    r!   r,   r   r   r   r   r*   u   s    r*   c                	   @   s:   e Zd ZdZd	dddedB dedB dee fddZdS )
AsyncEnumerateKeysProtocolz3Protocol segment to enumerate keys in a collection.Nlimitr   r0   r
   c                   r   )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   r0   r   r   r   r      r   zAsyncEnumerateKeysProtocol.keys)N)r   r    r!   r"   r#   r)   r(   r   r   r   r   r   r.      s    .r.   c                   @   s,   e Zd ZdddedB dee fddZdS )!AsyncEnumerateCollectionsProtocolNr/   r0   r
   c                   r   )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   r0   r   r   r   collections      z-AsyncEnumerateCollectionsProtocol.collections)r   r    r!   r)   r(   r#   r2   r   r   r   r   r1      s    $r1   c                   @   s   e Zd ZdZdefddZdS )AsyncDestroyStoreProtocolz1Protocol segment for store-destruction semantics.r
   c                    r   )z`Destroy the keystore.

        This will clear all collections and keys from the store.
        Nr   r+   r   r   r   destroy   r-   z!AsyncDestroyStoreProtocol.destroyN)r   r    r!   r"   r'   r5   r   r   r   r   r4      s    r4   c                   @   s   e Zd ZdedefddZdS )AsyncDestroyCollectionProtocolr   r
   c                    r   )zlDestroy the specified collection.

        Args:
            collection: The collection to destroy.
        Nr   )r   r   r   r   r   destroy_collection   r3   z1AsyncDestroyCollectionProtocol.destroy_collectionN)r   r    r!   r#   r'   r7   r   r   r   r   r6      s    r6   c                   @   s   e Zd ZdZdS )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   r   r   r   r8      s    r8   N)collections.abcr   typingr   r   r   r   r   r*   r.   r1   r4   r6   r8   r   r   r   r   <module>   s    o	

