1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

perf: cache the format of feeds

Detecting the format of a feed accounts for up to 30% of the time spent in
`parser.ParseFeed`. Cache the value once detected, as it'll never change.
This commit is contained in:
jvoisin 2025-02-04 16:12:31 +01:00
parent e342a4f143
commit c4a2afb7b7
12 changed files with 58 additions and 11 deletions

View file

@ -248,10 +248,12 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
apprise_service_urls,
webhook_url,
disable_http2,
description
description,
format,
format_version
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27)
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29)
RETURNING
id
`
@ -284,6 +286,8 @@ func (s *Storage) CreateFeed(feed *model.Feed) error {
feed.WebhookURL,
feed.DisableHTTP2,
feed.Description,
feed.Format,
feed.FormatVersion,
).Scan(&feed.ID)
if err != nil {
return fmt.Errorf(`store: unable to create feed %q: %v`, feed.FeedURL, err)
@ -363,9 +367,11 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) {
ntfy_priority=$32,
ntfy_topic=$33,
pushover_enabled=$34,
pushover_priority=$35
pushover_priority=$35,
format=$36,
format_version=$37
WHERE
id=$36 AND user_id=$37
id=$38 AND user_id=$39
`
_, err = s.db.Exec(query,
feed.FeedURL,
@ -403,6 +409,8 @@ func (s *Storage) UpdateFeed(feed *model.Feed) (err error) {
feed.NtfyTopic,
feed.PushoverEnabled,
feed.PushoverPriority,
feed.Format,
feed.FormatVersion,
feed.ID,
feed.UserID,
)

View file

@ -171,7 +171,9 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
f.ntfy_priority,
f.ntfy_topic,
f.pushover_enabled,
f.pushover_priority
f.pushover_priority,
f.format,
f.format_version
FROM
feeds f
LEFT JOIN
@ -246,6 +248,8 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) {
&feed.NtfyTopic,
&feed.PushoverEnabled,
&feed.PushoverPriority,
&feed.Format,
&feed.FormatVersion,
)
if err != nil {