Home / Function/ test_update_with_maxsize() — langchain Function Reference

test_update_with_maxsize() — langchain Function Reference

Architecture documentation for the test_update_with_maxsize() function in test_in_memory_cache.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  811e939e_7f3c_1e8f_8f12_ec95987188d8["test_update_with_maxsize()"]
  042e47a7_2d77_c7c3_bed8_c2072867e88c["test_in_memory_cache.py"]
  811e939e_7f3c_1e8f_8f12_ec95987188d8 -->|defined in| 042e47a7_2d77_c7c3_bed8_c2072867e88c
  ea5a68fd_3c0c_45fc_ad18_3358662ee70d["cache_item()"]
  811e939e_7f3c_1e8f_8f12_ec95987188d8 -->|calls| ea5a68fd_3c0c_45fc_ad18_3358662ee70d
  style 811e939e_7f3c_1e8f_8f12_ec95987188d8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/caches/test_in_memory_cache.py lines 52–69

def test_update_with_maxsize() -> None:
    """Test the update method of InMemoryCache with a maximum size."""
    cache = InMemoryCache(maxsize=2)

    prompt1, llm_string1, generations1 = cache_item(1)
    cache.update(prompt1, llm_string1, generations1)
    assert cache.lookup(prompt1, llm_string1) == generations1

    prompt2, llm_string2, generations2 = cache_item(2)
    cache.update(prompt2, llm_string2, generations2)
    assert cache.lookup(prompt2, llm_string2) == generations2

    prompt3, llm_string3, generations3 = cache_item(3)
    cache.update(prompt3, llm_string3, generations3)

    assert cache.lookup(prompt1, llm_string1) is None  # 'prompt1' should be evicted
    assert cache.lookup(prompt2, llm_string2) == generations2
    assert cache.lookup(prompt3, llm_string3) == generations3

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_update_with_maxsize() do?
test_update_with_maxsize() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/caches/test_in_memory_cache.py.
Where is test_update_with_maxsize() defined?
test_update_with_maxsize() is defined in libs/core/tests/unit_tests/caches/test_in_memory_cache.py at line 52.
What does test_update_with_maxsize() call?
test_update_with_maxsize() calls 1 function(s): cache_item.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free