@@ -35,7 +35,7 @@ func (p *Provider) Init(name string, _ *config.Config, _ log.Loggerer) error {
3535// Create method creates new in-memory cache with given options.
3636func (p * Provider ) Create (cfg * cache.Config ) (cache.Cache , error ) {
3737 p .cfg = cfg
38- c := & InMemory {
38+ c := & inMemory {
3939 cfg : p .cfg ,
4040 mu : sync.RWMutex {},
4141 entries : make (map [string ]entry ),
@@ -52,22 +52,22 @@ func (p *Provider) Create(cfg *cache.Config) (cache.Cache, error) {
5252// InMemory cache and implements cache.Cache interface
5353//______________________________________________________________________________
5454
55- // InMemory struct represents in-memory cache implementation.
56- type InMemory struct {
55+ // inMemory struct represents in-memory cache implementation.
56+ type inMemory struct {
5757 cfg * cache.Config
5858 mu sync.RWMutex
5959 entries map [string ]entry
6060}
6161
62- var _ cache.Cache = (* InMemory )(nil )
62+ var _ cache.Cache = (* inMemory )(nil )
6363
6464// Name method returns the cache store name.
65- func (im * InMemory ) Name () string {
65+ func (im * inMemory ) Name () string {
6666 return im .cfg .Name
6767}
6868
6969// Get method returns the cached entry for given key if it exists otherwise nil.
70- func (im * InMemory ) Get (k string ) interface {} {
70+ func (im * inMemory ) Get (k string ) interface {} {
7171 im .mu .RLock ()
7272 e , f := im .entries [k ]
7373 if f && ! e .IsExpired () {
@@ -88,7 +88,7 @@ func (im *InMemory) Get(k string) interface{} {
8888
8989// GetOrPut method returns the cached entry for the given key if it exists otherwise
9090// it puts the new entry into cache store and returns the value.
91- func (im * InMemory ) GetOrPut (k string , v interface {}, d time.Duration ) interface {} {
91+ func (im * inMemory ) GetOrPut (k string , v interface {}, d time.Duration ) interface {} {
9292 ev := im .Get (k )
9393 if ev == nil {
9494 _ = im .put (k , v , d )
@@ -99,24 +99,24 @@ func (im *InMemory) GetOrPut(k string, v interface{}, d time.Duration) interface
9999
100100// Put method adds the cache entry with specified expiration. Returns error
101101// if cache entry exists.
102- func (im * InMemory ) Put (k string , v interface {}, d time.Duration ) error {
102+ func (im * inMemory ) Put (k string , v interface {}, d time.Duration ) error {
103103 return im .put (k , v , d )
104104}
105105
106106// Delete method deletes the cache entry from cache store.
107- func (im * InMemory ) Delete (k string ) {
107+ func (im * inMemory ) Delete (k string ) {
108108 im .mu .Lock ()
109109 delete (im .entries , k )
110110 im .mu .Unlock ()
111111}
112112
113113// Exists method checks given key exists in cache store and its not expried.
114- func (im * InMemory ) Exists (k string ) bool {
114+ func (im * inMemory ) Exists (k string ) bool {
115115 return im .Get (k ) != nil
116116}
117117
118118// Flush methods flushes(deletes) all the cache entries from cache.
119- func (im * InMemory ) Flush () {
119+ func (im * inMemory ) Flush () {
120120 im .mu .Lock ()
121121 im .entries = make (map [string ]entry )
122122 im .mu .Unlock ()
@@ -126,7 +126,7 @@ func (im *InMemory) Flush() {
126126// Cache type's unexported methods
127127//______________________________________________________________________________
128128
129- func (im * InMemory ) put (k string , v interface {}, d time.Duration ) error {
129+ func (im * inMemory ) put (k string , v interface {}, d time.Duration ) error {
130130 if ev := im .Get (k ); ev == nil {
131131 var exp int64
132132 if d > 0 {
@@ -140,7 +140,7 @@ func (im *InMemory) put(k string, v interface{}, d time.Duration) error {
140140 return cache .ErrEntryExists
141141}
142142
143- func (im * InMemory ) startSweeper () {
143+ func (im * inMemory ) startSweeper () {
144144 ticker := time .NewTicker (im .cfg .SweepInterval )
145145 for {
146146 <- ticker .C
0 commit comments