Skip to content

Commit ed6cd8a

Browse files
authored
Merge pull request #16 from QIN2DIM/cleanupExpiredEntries
fix(cache): cleanup expired cache entries during update operations
2 parents 95d62f6 + 010b7ba commit ed6cd8a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/semantic-router/pkg/cache/cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func (c *SemanticCache) UpdateWithResponse(query string, responseBody []byte) er
108108
c.mu.Lock()
109109
defer c.mu.Unlock()
110110

111+
// Cleanup expired entries while we have the write lock
112+
c.cleanupExpiredEntries()
113+
111114
// Find the pending request by query
112115
for i, entry := range c.entries {
113116
if entry.Query == query && entry.ResponseBody == nil {

0 commit comments

Comments
 (0)