Skip to content

Commit f173a81

Browse files
committed
Formatting updates
1 parent b3f9be0 commit f173a81

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

background.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ func (km *keyMutex) Lock(key string) bool {
3636
}
3737

3838
func (m CacheMap) BackgroundUpdate(key string, updater func() (interface{}, error)) {
39-
//Lock the key from writes
39+
// Lock the key from writes
4040
locked := backgroundMutex.Lock(key)
4141
if locked {
42-
//Defer release write lock
42+
// Defer release write lock
4343
defer backgroundMutex.Unlock(key)
4444
value, err := updater()
4545
if err == nil {

cache_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ func TestGet(t *testing.T) {
2323
t.Errorf("Expected cache to return `world` for `hello`")
2424
}
2525

26-
//Check to see if cleanup is clearing unexpired items
26+
// Check to see if cleanup is clearing unexpired items
2727
time.Sleep(time.Millisecond * 200)
2828
data, exists = cache.Get("hello")
2929
if !exists || data == nil {
3030
t.Errorf("Expected cache to return data")
3131
}
3232

33-
//Check Cache is re-touching after a get
33+
// Check Cache is re-touching after a get
3434
time.Sleep(time.Millisecond * 200)
3535
data, exists = cache.Get("hello")
3636
if !exists || data == nil {
3737
t.Errorf("Expected cache to return data")
3838
}
3939

40-
//Check Cache is optionally re-touching after a get
40+
// Check Cache is optionally re-touching after a get
4141
time.Sleep(time.Millisecond * 200)
4242
data, exists = cache.TouchGet("hello", false)
4343
if !exists || data == nil {
4444
t.Errorf("Expected cache to return data")
4545
}
4646

47-
//Make sure cache clears after expiry
47+
// Make sure cache clears after expiry
4848
time.Sleep(time.Millisecond * 200)
4949
data, exists = cache.Get("hello")
5050
if exists || data != nil {
@@ -69,7 +69,7 @@ func TestMaxLifetime(t *testing.T) {
6969
t.Errorf("Expected cache to return `world` for `hello`")
7070
}
7171

72-
//Check to see if max lifetime has killed the item
72+
// Check to see if max lifetime has killed the item
7373
time.Sleep(time.Millisecond * 200)
7474
data, exists = cache.Get("hello")
7575
if exists || data != nil {

cleanup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func (ms *CacheMapShared) Flush() {
1414
ms.Unlock()
1515
}
1616

17-
//Cleanup removes any expired items from the cache map
17+
// Cleanup removes any expired items from the cache map
1818
func (ms *CacheMapShared) Cleanup() {
1919
ms.Lock()
2020
for key, item := range ms.items {

item.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ func newItem(value interface{}, duration time.Duration, deadline time.Time) *Ite
2525
return i
2626
}
2727

28-
//Touch increases the expiry time on the item by the TTL
28+
// Touch increases the expiry time on the item by the TTL
2929
func (i *Item) Touch() {
3030
i.Lock()
3131
expiration := time.Now().Add(i.ttl)
3232
i.expires = &expiration
3333
i.Unlock()
3434
}
3535

36-
//Expired returns if the item has passed its expiry time
36+
// Expired returns if the item has passed its expiry time
3737
func (i *Item) Expired() bool {
3838
var value bool
3939
i.RLock()
@@ -46,7 +46,7 @@ func (i *Item) Expired() bool {
4646
return value
4747
}
4848

49-
//GetValue represents the value of the item in the map
49+
// GetValue represents the value of the item in the map
5050
func (i *Item) GetValue() interface{} {
5151
return i.data
5252
}

opt.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ func defaultCacheOptions() cacheOptions {
2121
// CacheOption configures how we set up the cache map
2222
type CacheOption func(options *cacheOptions)
2323

24-
//WithShardSize With a custom sub map shard size
24+
// WithShardSize With a custom sub map shard size
2525
func WithShardSize(shardSize int) CacheOption {
2626
return func(o *cacheOptions) {
2727
o.shardCount = shardSize
2828
}
2929
}
3030

31-
//WithDefaultTTL Sets the default duration for items stored
31+
// WithDefaultTTL Sets the default duration for items stored
3232
func WithDefaultTTL(ttl time.Duration) CacheOption {
3333
return func(o *cacheOptions) {
3434
o.defaultCacheDuration = ttl
3535
}
3636
}
3737

38-
//WithCleanupDuration Sets how frequently to cleanup expired items
38+
// WithCleanupDuration Sets how frequently to cleanup expired items
3939
func WithCleanupDuration(ttl time.Duration) CacheOption {
4040
return func(o *cacheOptions) {
4141
o.cleanupDuration = ttl
4242
}
4343
}
4444

45-
//WithMaxLifetime Sets the maximum amount of time an item can exist within the cache
45+
// WithMaxLifetime Sets the maximum amount of time an item can exist within the cache
4646
func WithMaxLifetime(ttl time.Duration) CacheOption {
4747
return func(o *cacheOptions) {
4848
o.maxLifetime = ttl

0 commit comments

Comments
 (0)