Skip to content

Commit 8b03cab

Browse files
committed
all: imp docs, style
1 parent bdd2a7e commit 8b03cab

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

proxy/cache.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ func (c *cache) get(req *dns.Msg) (ci *cacheItem, expired bool, key []byte) {
245245
return ci, expired, key
246246
}
247247

248+
// isOptimisticExpired returns true if cache is optimistic and expired item
249+
// should be deleted explicitly. ci must not be nil.
248250
func (c *cache) isOptimisticExpired(ci *cacheItem) (expired bool) {
249251
return c.optimistic && uint32(time.Since(ci.createdTime).Seconds()) > ci.ttl+c.optimisticMaxAge
250252
}

proxy/cache_internal_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,17 @@ func TestCache_expired(t *testing.T) {
108108
wantTTL: defaultTestTTL,
109109
optimistic: false,
110110
}, {
111-
name: "realistic_miss",
112-
111+
name: "realistic_miss",
113112
ttl: 0,
114113
wantTTL: 0,
115114
optimistic: false,
116115
}, {
117-
name: "optimistic_hit",
118-
116+
name: "optimistic_hit",
119117
ttl: defaultTestTTL,
120118
wantTTL: defaultTestTTL,
121119
optimistic: true,
122120
}, {
123-
name: "optimistic_expired",
124-
121+
name: "optimistic_expired",
125122
ttl: 0,
126123
wantTTL: testOptimisticTTL,
127124
optimistic: true,

0 commit comments

Comments
 (0)