Skip to content

Commit 7ce81e2

Browse files
committed
test: use L1-only cache for getting-started timing test
CI has no Redis, so both calls were executing the full sleep. Fix: backend=None uses L1 (in-memory) cache which works everywhere.
1 parent f0e7ab7 commit 7ce81e2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/getting-started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,25 +345,25 @@ def cached_function():
345345
import time
346346
from cachekit import cache
347347

348-
@cache(ttl=60)
348+
@cache(ttl=60, backend=None) # L1-only (no Redis needed)
349349
def test_function(value):
350-
time.sleep(1) # Simulate expensive operation
350+
time.sleep(0.1) # Simulate expensive operation
351351
return f"processed_{value}"
352352

353-
# First call - should take ~1 second
353+
# First call - executes function
354354
start = time.time()
355355
result1 = test_function("test")
356356
duration1 = time.time() - start
357357
print(f"First call: {duration1:.3f}s, Result: {result1}")
358358

359-
# Second call - should be nearly instant
359+
# Second call - L1 cache hit
360360
start = time.time()
361361
result2 = test_function("test")
362362
duration2 = time.time() - start
363363
print(f"Second call: {duration2:.3f}s, Result: {result2}")
364364

365365
assert result1 == result2
366-
assert duration2 < 0.1 # Cache hit should be <100ms (generous for CI)
366+
assert duration2 < duration1 / 2 # Cache hit should be much faster
367367
print("Caching working correctly!")
368368
```
369369

0 commit comments

Comments
 (0)