Compare commits

..

1 Commits
v0.8.0 ... main

Author SHA1 Message Date
3ca245dadb
up 2025-08-09 19:13:59 +02:00
2 changed files with 14 additions and 1 deletions

View File

@ -194,3 +194,15 @@ func (c *Client) addToCache(longURL, shortID string) {
}) })
}() }()
} }
func (c *Client) remFromCache(longURL string) {
c.cacheMap.Remove(longURL)
// Async write to BoltDB
go func() {
_ = c.db.Update(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte("url_cache"))
return b.Delete([]byte(longURL))
})
}()
}

View File

@ -96,7 +96,8 @@ func (c *Client) enqueueJob(job shortenJob) {
select { select {
case c.retryQueue <- job: case c.retryQueue <- job:
default: default:
log.Println("Retry queue full, dropping job:", job.ID) log.Println("Retry queue full, dropping job and removing from caches:", job.ID, job.URL)
go c.remFromCache(job.URL)
} }
} }