aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 18:12:28 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 18:12:28 +0100
commit2ab1946a8b19b6b20abb38d79c021ca6be8bfb40 (patch)
tree6937f6612928ba69d967dcfa6849a8613a4ee48d /internal/feed/cache
parentebb116894852676d3779159dedea1ac648d11b35 (diff)
downloadfeed2imap-go-2ab1946a8b19b6b20abb38d79c021ca6be8bfb40.tar.gz
feed2imap-go-2ab1946a8b19b6b20abb38d79c021ca6be8bfb40.tar.bz2
feed2imap-go-2ab1946a8b19b6b20abb38d79c021ca6be8bfb40.zip
Improve output of `print-cache`
Diffstat (limited to 'internal/feed/cache')
-rw-r--r--internal/feed/cache/cache_v1.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/feed/cache/cache_v1.go b/internal/feed/cache/cache_v1.go
index 439846f..f7392e5 100644
--- a/internal/feed/cache/cache_v1.go
+++ b/internal/feed/cache/cache_v1.go
@@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/hex"
"fmt"
+ "sort"
"strconv"
"strings"
"time"
@@ -111,9 +112,22 @@ func (cache *v1Cache) Version() Version {
}
func (cache *v1Cache) Info() string {
+ descriptors := make([]feed.Descriptor, len(cache.Ids))
+ i := 0
+ for descr := range cache.Ids {
+ descriptors[i] = descr
+ i++
+ }
+
+ sort.Slice(descriptors, func(i, j int) bool {
+ return descriptors[i].Name < descriptors[j].Name
+ })
+
b := strings.Builder{}
- for descr, id := range cache.Ids {
- b.WriteString(fmt.Sprintf("%3s: %s (%s)\n", id.String(), descr.Name, descr.Url))
+ for _, descr := range descriptors {
+ id := cache.Ids[descr]
+ feed := cache.Feeds[id]
+ b.WriteString(fmt.Sprintf("%3s: %s (%s) (%d items)\n", id.String(), descr.Name, descr.Url, len(feed.Items)))
}
return b.String()
}
s='nohover-highlight'> Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-10Add caching infrastructureLars Hjemli9-28/+353 This enables internal caching of page output. Page requests are split into four groups: 1) repo listing (front page) 2) repo summary 3) repo pages w/symbolic references in query string 4) repo pages w/constant sha1's in query string Each group has a TTL specified in minutes. When a page is requested, a cached filename is stat(2)'ed and st_mtime is compared to time(2). If TTL has expired (or the file didn't exist), the cached file is regenerated. When generating a cached file, locking is used to avoid parallell processing of the request. If multiple processes tries to aquire the same lock, the ones who fail to get the lock serves the (expired) cached file. If the cached file don't exist, the process instead calls sched_yield(2) before restarting the request processing. Signed-off-by: Lars Hjemli <hjemli@gmail.com>