about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--svc/cache.go23
-rw-r--r--svc/db.go8
-rw-r--r--svc/db_test.go4
3 files changed, 10 insertions, 25 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
-}
diff --git a/svc/db.go b/svc/db.go
index 10ea28d..2289771 100644
--- a/svc/db.go
+++ b/svc/db.go
@@ -37,10 +37,10 @@ func initDatabase() {
 
 	dbChan <- db
 
-	pullDatabase()
+	pullDB()
 }
 
-func checkDBtime() bool {
+func dbTimer() bool {
 	confObj.Mu.RLock()
 	answer := time.Since(confObj.LastPush) > confObj.DBInterval
 	confObj.Mu.RUnlock()
@@ -50,14 +50,14 @@ func checkDBtime() bool {
 
 // Pushes the registry's cache data to a local
 // database for safe keeping.
-func pushDatabase() error {
+func pushDB() error {
 	db := <-dbChan
 	dbChan <- db
 
 	return db.push()
 }
 
-func pullDatabase() {
+func pullDB() {
 	db := <-dbChan
 	dbChan <- db
 	db.pull()
diff --git a/svc/db_test.go b/svc/db_test.go
index 071936e..f3252c6 100644
--- a/svc/db_test.go
+++ b/svc/db_test.go
@@ -73,7 +73,7 @@ func Benchmark_pushDatabase(b *testing.B) {
 	b.ResetTimer()
 
 	for i := 0; i < b.N; i++ {
-		err := pushDatabase()
+		err := pushDB()
 		if err != nil {
 			b.Errorf("%v\n", err)
 		}
@@ -87,6 +87,6 @@ func Benchmark_pullDatabase(b *testing.B) {
 	}
 
 	for i := 0; i < b.N; i++ {
-		pullDatabase()
+		pullDB()
 	}
 }