
    Zi6                    >   S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	J
r
JrJr  \" S5      r\S   r SSKJr  SS	KJr   SSKJr  SSKJr  / SQrSS jrS
S.SS jjrS
S
S
S.           SS jjrg
! \ a    S
rS
r NBf = f! \ a    S
r " S S\
\   5      r NQf = f)zKey/value cache for use inside LangGraph deployments.

Thin wrapper around ``langgraph_api.cache``.
Values must be JSON-serializable (dicts, lists, strings, numbers, booleans,
``None``).
    )annotations)	AwaitableCallable)	timedelta)AnyGenericLiteralTypeVarT)missfreshstaleexpired)	cache_get)	cache_setN)	SWRResult)swrc                  <    \ rS rSr% SrS\S'   S\S'   S
SS jjrSrg	)r   %   z'Result wrapper returned by :func:`swr`.r   valueCacheStatusstatusc                   #    g7f)z&Update or revalidate the cached value.N )selfr   s     m/var/www/eduai.edurigo.com/question_generate/ques_gen_env/lib/python3.13/site-packages/langgraph_sdk/cache.pymutateSWRResult.mutate+   s     s   r   N).)r   r   returnr   )__name__
__module____qualname____firstlineno____doc____annotations__r   __static_attributes__r       r   r   r   %   s    5	 	r'   r   )r   r   r   r   c                X   #    [         c  [        S5      e[        U 5      I Sh  vN $  N7f)zGet a value from the cache.

Returns the deserialized value, or ``None`` if the key is missing or expired.

Requires Agent Server runtime version 0.7.29 or later.
NyCache is only available server-side within the LangGraph Agent Server (https://docs.langchain.com/langsmith/deployments).)
_cache_getRuntimeError)keys    r   r   r   8   s2      B
 	
 C   s   !*(*)ttlc               \   #    [         c  [        S5      e[        XU5      I Sh  vN   g N7f)a	  Set a value in the cache.

Args:
    key: The cache key.
    value: The value to cache (must be JSON-serializable).
    ttl: Optional time-to-live. Capped at 1 day; ``None`` or zero
        defaults to 1 day.

Requires Agent Server runtime version 0.7.29 or later.
Nr)   )
_cache_setr+   )r,   r   r-   s      r   r   r   G   s2      B
 	
 S
%%%s   ",*,	fresh_formax_agemodelc                  #    [         c  [        S5      eUc  [        S5      nUc	  [        SS9n[        XX#US9I Sh  vN $  N7f)a  Load a cached value using stale-while-revalidate semantics.

This helper is server-side only and is intended for caching internal async
dependencies such as auth or metadata lookups.

Args:
    key: Cache key.
    loader: Async callable that fetches the value on miss/revalidation.
    fresh_for: How long a cached value is considered fresh (no revalidation).
        Defaults to ``timedelta(0)`` so every access triggers a background
        revalidate while still returning the cached value instantly. Values
        above :data:`MAX_CACHE_TTL` are clamped to the backend maximum.
    max_age: Total lifetime of a cached entry. After this, the next access
        blocks on the loader. Defaults to :data:`MAX_CACHE_TTL` (24 h by
        default). Values above :data:`MAX_CACHE_TTL` are clamped to the
        backend maximum.
    model: Optional Pydantic model class. When provided, values are
        serialized via ``model_dump(mode="json")`` before storage and
        deserialized via ``model.model_validate()`` on read.

Returns:
    An :class:`SWRResult` with ``.value``, ``.status``, and an async
    ``.mutate()`` method.

Semantics:
- cache miss: await ``loader()``, store the value, return it
- fresh hit (age < fresh_for): return the cached value
- stale hit (fresh_for <= age < max_age): return the cached value
  immediately and trigger a best-effort background refresh
- expired (age >= max_age): await ``loader()``, store the value, return it
Nr)   r      )daysr0   )_api_swrr+   r   )r,   loaderr1   r2   r3   s        r   r   r   Z   s_     N B
 	
 aL	#y   s   ;AAA)r,   strr   z
Any | None)r,   r9   r   r   r-   timedelta | Noner   None)r,   r9   r8   zCallable[[], Awaitable[T]]r1   r:   r2   r:   r3   ztype[T] | Noner   zSWRResult[T])r$   
__future__r   collections.abcr   r   datetimer   typingr   r   r	   r
   r   r   langgraph_api.cacher   r*   r   r/   ImportErrorr   r   r7   __all__r   r'   r   <module>rC      s    # /  1 1CL9:	-3 ! FJ &. #' $ 2	2&2  	2
 2 2 2C  JJ  HGAJ s"   A3 B 3
B ?B BB