summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
Diffstat (limited to 'svc')
-rw-r--r--svc/cache.go3
-rw-r--r--svc/cache_test.go28
-rw-r--r--svc/conf.go5
-rw-r--r--svc/init_test.go4
-rw-r--r--svc/leveldb.go4
-rw-r--r--svc/sqlite.go4
6 files changed, 10 insertions, 38 deletions
diff --git a/svc/cache.go b/svc/cache.go
index 3383016..d3ac872 100644
--- a/svc/cache.go
+++ b/svc/cache.go
@@ -66,9 +66,6 @@ func cacheUpdate() {
 		errLog("Error refreshing local copy of remote registry data: ", twtxtCache.CrawlRemoteRegistry(v))
 	}
 	remoteRegistries.Mu.RUnlock()
-	confObj.Mu.Lock()
-	confObj.LastCache = time.Now()
-	confObj.Mu.Unlock()
 }
 
 // pingAssets checks if the local static assets
diff --git a/svc/cache_test.go b/svc/cache_test.go
index 28e5c0b..2177917 100644
--- a/svc/cache_test.go
+++ b/svc/cache_test.go
@@ -4,26 +4,9 @@ import (
 	"testing"
 )
 
-func Test_cacheUpdate(t *testing.T) {
-	initTestConf()
-	confObj.Mu.RLock()
-	prevtime := confObj.LastCache
-	confObj.Mu.RUnlock()
-
-	t.Run("Cache Time Check", func(t *testing.T) {
-		cacheUpdate()
-		confObj.Mu.RLock()
-		newtime := confObj.LastCache
-		confObj.Mu.RUnlock()
-
-		if !newtime.After(prevtime) || newtime == prevtime {
-			t.Errorf("Cache time did not update, check cacheUpdate() logic\n")
-		}
-	})
-}
-
 func Benchmark_cacheUpdate(b *testing.B) {
 	initTestConf()
+	mockRegistry()
 	b.ResetTimer()
 
 	for i := 0; i < b.N; i++ {
@@ -37,5 +20,14 @@ func Benchmark_pingAssets(b *testing.B) {
 
 	for i := 0; i < b.N; i++ {
 		pingAssets()
+
+		// We'll only have to reload the cache occasionally,
+		// so only start with an empty staticCache 25% of
+		// the time.
+		if float64(i) > (float64(b.N) * .75) {
+			b.StopTimer()
+			staticCache = &staticAssets{}
+			b.StartTimer()
+		}
 	}
 }
diff --git a/svc/conf.go b/svc/conf.go
index ccd819c..8abb4a6 100644
--- a/svc/conf.go
+++ b/svc/conf.go
@@ -24,8 +24,6 @@ type Configuration struct {
 	StdoutLogging bool          `yaml:"StdoutLogging"`
 	CacheInterval time.Duration `yaml:"StatusFetchInterval"`
 	DBInterval    time.Duration `yaml:"DatabasePushInterval"`
-	LastCache     time.Time     `yaml:"-"`
-	LastPush      time.Time     `yaml:"-"`
 	Instance      `yaml:"Instance"`
 }
 
@@ -249,9 +247,6 @@ func bindConfig() {
 	confObj.DBInterval = viper.GetDuration("DatabasePushInterval")
 	log.Printf("Database push interval: %v\n", confObj.DBInterval)
 
-	confObj.LastCache = time.Now()
-	confObj.LastPush = time.Now()
-
 	confObj.Instance.Vers = Vers
 	confObj.Instance.Name = viper.GetString("Instance.SiteName")
 	confObj.Instance.URL = viper.GetString("Instance.URL")
diff --git a/svc/init_test.go b/svc/init_test.go
index 51c969a..8b68839 100644
--- a/svc/init_test.go
+++ b/svc/init_test.go
@@ -7,7 +7,6 @@ import (
 	"os"
 	"strings"
 	"sync"
-	"time"
 
 	"github.com/getwtxt/registry"
 	"github.com/spf13/viper"
@@ -80,9 +79,6 @@ func testConfig() {
 	confObj.DBInterval = viper.GetDuration("DatabasePushInterval")
 	log.Printf("Database push interval: %v\n", confObj.DBInterval)
 
-	confObj.LastCache = time.Now()
-	confObj.LastPush = time.Now()
-
 	confObj.Instance.Vers = Vers
 	confObj.Instance.Name = viper.GetString("Instance.SiteName")
 	confObj.Instance.URL = viper.GetString("Instance.URL")
diff --git a/svc/leveldb.go b/svc/leveldb.go
index c39bcbf..36b7946 100644
--- a/svc/leveldb.go
+++ b/svc/leveldb.go
@@ -38,10 +38,6 @@ func (lvl *dbLevel) push() error {
 	}
 	remoteRegistries.Mu.RUnlock()
 
-	confObj.Mu.Lock()
-	confObj.LastPush = time.Now()
-	confObj.Mu.Unlock()
-
 	return lvl.db.Write(dbBasket, nil)
 }
 
diff --git a/svc/sqlite.go b/svc/sqlite.go
index 40a7ff2..dd6d6de 100644
--- a/svc/sqlite.go
+++ b/svc/sqlite.go
@@ -43,10 +43,6 @@ func initSqlite() *dbSqlite {
 }
 
 func (lite *dbSqlite) push() error {
-	confObj.Mu.Lock()
-	confObj.LastPush = time.Now()
-	confObj.Mu.Unlock()
-
 	if err := lite.db.Ping(); err != nil {
 		lite = initSqlite()
 	}
=v1.9.0b1&id=7536711856a5ee840314fa4e7c80bef2d31e4bdf'>^
6a5d09b8 ^






0b306138 ^
6a5d09b8 ^
65cb1a32 ^
9e63489a ^
f8e96a97 ^
9e63489a ^
9506fb8e ^

91e5b943 ^
0b306138 ^
6a5d09b8 ^
bd33933d ^
9506fb8e ^
3547d300 ^






9e63489a ^















9506fb8e ^
728fb838 ^
ea87d005 ^
67bb838c ^



91e5b943 ^
9506fb8e ^

728fb838 ^
5645f266 ^
ea87d005 ^
9506fb8e ^
1f62d7db ^


b4b0eb24 ^
1f62d7db ^

9506fb8e ^





1f62d7db ^







dd7a4f63 ^
1f62d7db ^
419e4aa5 ^

dd7a4f63 ^
1f62d7db ^
871c502d ^
9b83f114 ^
728fb838 ^
9b83f114 ^
871c502d ^
50a676b4 ^

9b83f114 ^


e3f6f484 ^

ea87d005 ^
3201b163 ^
766a5b6a ^

3201b163 ^
ea87d005 ^
9506fb8e ^
728fb838 ^
3d566884 ^
9506fb8e ^


3201b163 ^


ea87d005 ^
a1274aba ^
eaaeed3d ^
a1274aba ^
9506fb8e ^
89660a64 ^
728fb838 ^
dd7a4f63 ^

419e4aa5 ^

dd7a4f63 ^

5599636d ^
419e4aa5 ^
ea87d005 ^
581cce8c ^
766a5b6a ^

581cce8c ^
45cb587d ^
728fb838 ^
4162b636 ^
bd33933d ^
45cb587d ^

728fb838 ^
4162b636 ^
cc952d63 ^

227f75db ^

9506fb8e ^
419e4aa5 ^
9506fb8e ^
e48e3c5c ^
3ea48208 ^
c6953a55 ^
3ea48208 ^
ecd0d386 ^



9506fb8e ^
766a5b6a ^
9506fb8e ^
766a5b6a ^
9506fb8e ^








3d566884 ^
9506fb8e ^


89660a64 ^
dd7a4f63 ^
9506fb8e ^
876e288a ^

766a5b6a ^

419e4aa5 ^
45cb587d ^
766a5b6a ^
45cb587d ^
227f75db ^

3ea48208 ^
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222