diff options
Diffstat (limited to 'svc/cache.go')
-rw-r--r-- | svc/cache.go | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/svc/cache.go b/svc/cache.go index ce3813c..fb6a9ab 100644 --- a/svc/cache.go +++ b/svc/cache.go @@ -8,7 +8,7 @@ import ( "time" ) -func checkCacheTime() bool { +func cacheTimer() bool { confObj.Mu.RLock() answer := time.Since(confObj.LastCache) > confObj.CacheInterval confObj.Mu.RUnlock() @@ -20,11 +20,11 @@ func checkCacheTime() bool { // for the update intervals to pass. func cacheAndPush() { for { - if checkCacheTime() { + if cacheTimer() { refreshCache() } - if checkDBtime() { - if err := pushDatabase(); err != nil { + if dbTimer() { + if err := pushDB(); err != nil { log.Printf("Error pushing cache to database: %v\n", err.Error()) } } @@ -113,18 +113,3 @@ func pingAssets() { staticCache.cssMod = cssStat.ModTime() } } - -// Simple function to deduplicate entries in a []string -func dedupe(list []string) []string { - var out []string - var seen = map[string]bool{} - - for _, e := range list { - if !seen[e] { - out = append(out, e) - seen[e] = true - } - } - - return out -} |