Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

SemanticCache.check() unconditionally refreshes TTL on hit (sliding-window with no opt-out)

Đang mở
#603 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

@omribz156 đang làm issue này rồi.

Từ ngày 25/5/2026.

  • #618 của @omribz156 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
70/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python, redis

Hướng nghiên cứu

Bắt đầu trong redisvl/extensions/cache/llm/semantic.py tại SemanticCache.check(), quanh dòng 432, sau đó đọc constructor SemanticCache xung quanh và đường dẫn làm mới TTL hiện tại. Xác minh rằng cờ constructor được đề xuất và override theo mỗi lần gọi vẫn giữ nguyên hành vi mặc định, đồng thời cho phép chỉ đọc khi bị tắt; hoàn thành khi cả hai tùy chọn đều được hỗ trợ mà không thay đổi các caller hiện có.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

cache enhancement

Current behavior

SemanticCache.check (redisvl/extensions/cache/llm/semantic.py:432) refreshes the TTL of every matched entry on every hit:

# Refresh TTL on all found keys
for key in redis_keys:
    self.expire(key)

This is a sliding-window TTL: a popular entry effectively lives as long as it keeps getting hit. There is no constructor flag, per-call argument, or per-entry attribute to disable this.

Why this is a problem

Sliding window is the wrong default in any domain where the popularity of an entry correlates with the cost of it being stale:

  • a procedure superseded by a regulatory bulletin that the cache has not yet invalidated
  • a balance-patch-affected gameplay answer in a live-ops surface
  • a pricing or eligibility answer that changed at midnight

In these domains the most-asked question is the most likely to be cached and the most likely to fan out a stale answer. The standard mitigation today — store an absolute expires_at numeric and filter on it at read time — works but requires every customer to discover the pattern independently.

Proposed API

SemanticCache(
    name="cache",
    redis_url=...,
    refresh_ttl_on_hit=True,    # current behavior, default unchanged
)

cache.check(
    prompt=...,
    refresh_ttl=None,           # per-call override
)

refresh_ttl_on_hit=False would make check() a pure read. Customers wanting absolute expiry would set this to False, store a numeric expires_at filterable field, and filter on it.

Backwards compatibility

Default remains True. Existing behavior unchanged. Opt-in behavioral change for customers who need it.

Notes

Surfaced while writing a scoped semantic caching architecture spec; came up repeatedly when stress-testing the design against regulated and fast-mutating domains where sliding-window TTL is actively hostile.

Ngôn ngữ chính
Python
Star
432
Fork
111
Merge trung bình
5 ngày 22 giờ
Pull request đã merge (30 ngày)
13

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của redis/redis-vl-python

Tất cả issue của redis/redis-vl-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.