Skip to content

Commit 6892ce3

Browse files
committed
Changed cache function visibility
1 parent 3fd3b98 commit 6892ce3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

cache.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ type portsCache struct {
4444
deletionCallback func(port *discovery.Port)
4545
}
4646

47-
// NewCache creates a new portsCache and returns it.
47+
// newCache creates a new portsCache and returns it.
4848
// itemsTTL is the TTL of a single item, when it's reached
4949
// the stored item is deleted.
50-
func NewCache(itemsTTL time.Duration) *portsCache {
50+
func newCache(itemsTTL time.Duration) *portsCache {
5151
return &portsCache{
5252
itemsTTL: itemsTTL,
5353
data: make(map[string]*cacheItem),
5454
}
5555
}
5656

57-
// Set stores a new port and sets its TTL.
57+
// set stores a new port and sets its TTL.
5858
// If the specified key is already found the item's TTL is
5959
// renewed.
60-
// Set is thread safe.
61-
func (c *portsCache) Set(key string, port *discovery.Port) {
60+
// set is thread safe.
61+
func (c *portsCache) set(key string, port *discovery.Port) {
6262
c.dataMutex.Lock()
6363
defer c.dataMutex.Unlock()
6464
// We need a cancellable context to avoid leaving
@@ -105,10 +105,10 @@ func (c *portsCache) Set(key string, port *discovery.Port) {
105105
}(key, item)
106106
}
107107

108-
// Get returns the item stored with the specified key and true.
108+
// get returns the item stored with the specified key and true.
109109
// If the item is not found returns a nil port and false.
110-
// Get is thread safe.
111-
func (c *portsCache) Get(key string) (*discovery.Port, bool) {
110+
// get is thread safe.
111+
func (c *portsCache) get(key string) (*discovery.Port, bool) {
112112
c.dataMutex.Lock()
113113
defer c.dataMutex.Unlock()
114114
if item, ok := c.data[key]; ok {
@@ -117,9 +117,9 @@ func (c *portsCache) Get(key string) (*discovery.Port, bool) {
117117
return nil, false
118118
}
119119

120-
// Clear removes all the stored items and stops their TTL timers.
121-
// Clear is thread safe.
122-
func (c *portsCache) Clear() {
120+
// clear removes all the stored items and stops their TTL timers.
121+
// clear is thread safe.
122+
func (c *portsCache) clear() {
123123
c.dataMutex.Lock()
124124
defer c.dataMutex.Unlock()
125125
for key, item := range c.data {

0 commit comments

Comments
 (0)