Skip to content

Commit e7825fa

Browse files
committed
fix: rename pointer receiver in Cache
1 parent 14b5ed9 commit e7825fa

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

internal/ldap_cache/cache.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@ func NewCached[T cacheable]() Cache[T] {
1919
}
2020
}
2121

22-
func (i *Cache[T]) setAll(v []T) {
23-
i.m.Lock()
24-
defer i.m.Unlock()
22+
func (c *Cache[T]) setAll(v []T) {
23+
c.m.Lock()
24+
defer c.m.Unlock()
2525

26-
i.items = v
26+
c.items = v
2727
}
2828

29-
func (i *Cache[T]) update(fn func(*T)) {
30-
i.m.Lock()
31-
defer i.m.Unlock()
29+
func (c *Cache[T]) update(fn func(*T)) {
30+
c.m.Lock()
31+
defer c.m.Unlock()
3232

33-
for idx, item := range i.items {
33+
for idx, item := range c.items {
3434
fn(&item)
35-
i.items[idx] = item
35+
c.items[idx] = item
3636
}
3737
}
3838

39-
func (i *Cache[T]) Get() []T {
40-
i.m.RLock()
41-
defer i.m.RUnlock()
39+
func (c *Cache[T]) Get() []T {
40+
c.m.RLock()
41+
defer c.m.RUnlock()
4242

43-
return i.items
43+
return c.items
4444
}
4545

46-
func (i *Cache[T]) Find(fn func(T) bool) (v *T, found bool) {
47-
i.m.RLock()
48-
defer i.m.RUnlock()
46+
func (c *Cache[T]) Find(fn func(T) bool) (v *T, found bool) {
47+
c.m.RLock()
48+
defer c.m.RUnlock()
4949

50-
for _, item := range i.items {
50+
for _, item := range c.items {
5151
if fn(item) {
5252
return &item, true
5353
}
@@ -56,17 +56,17 @@ func (i *Cache[T]) Find(fn func(T) bool) (v *T, found bool) {
5656
return nil, false
5757
}
5858

59-
func (i *Cache[T]) FindByDN(dn string) (v *T, found bool) {
60-
return i.Find(func(v T) bool {
59+
func (c *Cache[T]) FindByDN(dn string) (v *T, found bool) {
60+
return c.Find(func(v T) bool {
6161
return v.DN() == dn
6262
})
6363
}
6464

65-
func (i *Cache[T]) Filter(fn func(T) bool) (v []T) {
66-
i.m.RLock()
67-
defer i.m.RUnlock()
65+
func (c *Cache[T]) Filter(fn func(T) bool) (v []T) {
66+
c.m.RLock()
67+
defer c.m.RUnlock()
6868

69-
for _, item := range i.items {
69+
for _, item := range c.items {
7070
if fn(item) {
7171
v = append(v, item)
7272
}
@@ -75,9 +75,9 @@ func (i *Cache[T]) Filter(fn func(T) bool) (v []T) {
7575
return v
7676
}
7777

78-
func (i *Cache[T]) Count() int {
79-
i.m.RLock()
80-
defer i.m.RUnlock()
78+
func (c *Cache[T]) Count() int {
79+
c.m.RLock()
80+
defer c.m.RUnlock()
8181

82-
return len(i.items)
82+
return len(c.items)
8383
}

0 commit comments

Comments
 (0)