Commit 20c66f2
committed
Fix: Remove spl_object_id() from cache key generation to enable cache hits
Root cause: Perpetual cache MISS due to spl_object_id() in callback hash
PROBLEM:
- Line 60 used: md5(spl_object_id($queryCallback))
- Each HTTP request creates a NEW Closure instance
- spl_object_id() is unique per object instance, not per behavior
- Same code path produces different object ID every request
- Result: Cache key always different, never reuses cached data
SYMPTOMS:
✓ Every request reports X-Cache-Status: MISS
✓ Redis shows growing number of cache keys
✓ Cache TTLs expire unused
✓ No stampedes, but no hits either
SOLUTION:
- Removed callback_hash from additionalParams
- Keep has_callback flag for debugging
- Callback effects already captured by request parameters
- Company UUID, filters, sorts already in cache key
- Cache versioning handles invalidation
AFTER THIS FIX:
- First request: MISS (cache empty)
- Subsequent identical requests: HIT
- Cache reuse now works correctly
Reference: Laravel_Cache_spl_object_id_Callback_Key_Issue_AI_Guide.pdf1 parent 657f1c0 commit 20c66f2
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | | - | |
60 | | - | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
0 commit comments