Skip to content

feat(cache): add cache eviction and concurrency tests#68

Open
KingingWang wants to merge 1 commit into
mainfrom
feat/cache-eviction-tests
Open

feat(cache): add cache eviction and concurrency tests#68
KingingWang wants to merge 1 commit into
mainfrom
feat/cache-eviction-tests

Conversation

@KingingWang
Copy link
Copy Markdown
Owner

Summary

  • Add as_any() method to Cache trait for downcasting in tests
  • Add comprehensive cache eviction tests (TTL expiration, capacity-based)
  • Add concurrent access tests (reads, writes, mixed operations, race conditions)

Changes

  • src/cache/mod.rs: Add as_any() to Cache trait
  • src/cache/memory.rs: Implement as_any() for MemoryCache
  • src/cache/redis.rs: Implement as_any() for RedisCache
  • tests/unit/cache_tests.rs: Add 7 new tests covering:
    • TTL expiration behavior
    • Capacity-based eviction under pressure
    • Independent TTLs for different cache types
    • 100 concurrent reads
    • 50 concurrent writes
    • 90 mixed concurrent operations
    • Race condition read-after-write

Test plan

  • All 24 cache tests pass
  • cargo clippy --all-targets -- -D warnings passes
  • cargo fmt -- --check passes

@KingingWang
Copy link
Copy Markdown
Owner Author

ProviderModelNotFoundError

opencode session  |  github run

…tests

Add `as_any()` method to Cache trait and its implementations (MemoryCache, RedisCache) to enable downcasting for test purposes. Also add unit tests for cache TTL expiration, capacity-based eviction, and independent TTLs for different cache types.
@KingingWang KingingWang force-pushed the feat/cache-eviction-tests branch from 1942054 to 01fa67b Compare April 9, 2026 06:56
@KingingWang
Copy link
Copy Markdown
Owner Author

ProviderModelNotFoundError

opencode session  |  github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant