summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-11 12:18:38 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-11 12:18:38 +0100
commitedcee14d07bae129e2d1a06d99c30fc6f659ff5e (patch)
tree5b9d605654347fe104c55bf4b0e7fb1e1533e2a0 /vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
parent[feature] S3: add config flag to proxy S3 media (#1014) (diff)
downloadgotosocial-edcee14d07bae129e2d1a06d99c30fc6f659ff5e.tar.xz
[feature] Read + Write tombstones for deleted Actors (#1005)
* [feature] Read + Write tombstones for deleted Actors * copyTombstone * update to use resultcache instead of old ttl cache Signed-off-by: kim <grufwub@gmail.com> * update go-cache library to fix result cache capacity / ordering bugs Signed-off-by: kim <grufwub@gmail.com> * bump go-cache/v3 to v3.1.6 to fix bugs Signed-off-by: kim <grufwub@gmail.com> * switch on status code * better explain ErrGone reasoning Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go')
-rw-r--r--vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go b/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
new file mode 100644
index 000000000..111de0757
--- /dev/null
+++ b/vendor/codeberg.org/gruf/go-cache/v3/ttl/schedule.go
@@ -0,0 +1,20 @@
+package ttl
+
+import (
+ "time"
+
+ "codeberg.org/gruf/go-sched"
+)
+
+// scheduler is the global cache runtime scheduler
+// for handling regular cache evictions.
+var scheduler sched.Scheduler
+
+// schedule will given sweep routine to the global scheduler, and start global scheduler.
+func schedule(sweep func(time.Time), freq time.Duration) func() {
+ if !scheduler.Running() {
+ // ensure running
+ _ = scheduler.Start()
+ }
+ return scheduler.Schedule(sched.NewJob(sweep).Every(freq))
+}