mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(feeds): improve caching (#1191)
* feat(feeds): improve caching * fix(feeds): put cache if not empty * fix(feeds): reassign loop var * fix(feeds): enable busy_timeout again * fix(feeds): enable busy_timeout again
This commit is contained in:
parent
8c7c147328
commit
9793764905
6 changed files with 88 additions and 22 deletions
|
@ -175,6 +175,27 @@ func (r *FeedCacheRepo) Put(feedId int, key string, val []byte, ttl time.Time) e
|
|||
return nil
|
||||
}
|
||||
|
||||
func (r *FeedCacheRepo) PutMany(ctx context.Context, items []domain.FeedCacheItem) error {
|
||||
queryBuilder := r.db.squirrel.
|
||||
Insert("feed_cache").
|
||||
Columns("feed_id", "key", "value", "ttl")
|
||||
|
||||
for _, item := range items {
|
||||
queryBuilder = queryBuilder.Values(item.FeedId, item.Key, item.Value, item.TTL)
|
||||
}
|
||||
|
||||
query, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error building query")
|
||||
}
|
||||
|
||||
if _, err = r.db.handler.ExecContext(ctx, query, args...); err != nil {
|
||||
return errors.Wrap(err, "error executing query")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *FeedCacheRepo) Delete(ctx context.Context, feedId int, key string) error {
|
||||
queryBuilder := r.db.squirrel.
|
||||
Delete("feed_cache").
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue