mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-26 22:59:57 +00:00
## Summary - Exposes `Session` in Python and Typescript so users can set the `index_cache_size_bytes` and `metadata_cache_size_bytes` * The `Session` is attached to the `Connection`, and thus shared across all tables in that connection. - Adds deprecation warnings for table-level cache configuration 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
import lancedb
|
|
|
|
|
|
def test_session_cache_configuration(tmp_path):
|
|
"""Test Session cache configuration and basic functionality."""
|
|
# Create session with small cache limits for testing
|
|
index_cache_size = 1024 * 1024 # 1MB
|
|
metadata_cache_size = 512 * 1024 # 512KB
|
|
|
|
session = lancedb.Session(
|
|
index_cache_size_bytes=index_cache_size,
|
|
metadata_cache_size_bytes=metadata_cache_size,
|
|
)
|
|
|
|
# Record initial cache state
|
|
initial_cache_size = session.size_bytes
|
|
initial_cache_items = session.approx_num_items
|
|
|
|
# Test session works with database connection
|
|
db = lancedb.connect(tmp_path, session=session)
|
|
|
|
# Create and use a table to exercise the session
|
|
data = [{"id": i, "text": f"item {i}"} for i in range(100)]
|
|
table = db.create_table("test", data)
|
|
results = list(table.to_arrow().to_pylist())
|
|
|
|
assert len(results) == 100
|
|
|
|
# Verify cache usage increased after operations
|
|
final_cache_size = session.size_bytes
|
|
final_cache_items = session.approx_num_items
|
|
|
|
assert final_cache_size > initial_cache_size # Cache should have grown
|
|
assert final_cache_items >= initial_cache_items # Items should not decrease
|
|
assert initial_cache_size < index_cache_size + metadata_cache_size
|