File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,10 @@ import (
77 mgo "gopkg.in/mgo.v2"
88)
99
10- // MongoCache ...
10+ // MongoCache holds the cache values that will be stored in mongoDB
1111type MongoCache struct {
1212 mongeSession * mgo.Session
1313 // cache holds the cache data
14- // cache *KeyValue
1514
1615 CollectionName string
1716 // ttl is a duration for a cache key to expire
@@ -89,6 +88,7 @@ func (m *MongoCache) set(key string, value interface{}) error {
8988 return m .CreateKeyValueWithExpiration (kv )
9089}
9190
91+ // StartGCol starts the garbage collector with given time interval
9292func (m * MongoCache ) StartGCol (gcInterval time.Duration ) {
9393 if gcInterval <= 0 {
9494 return
@@ -115,3 +115,15 @@ func (m *MongoCache) StartGCol(gcInterval time.Duration) {
115115 }
116116 }()
117117}
118+
119+ // StopGC stops sweeping goroutine.
120+ func (r * MemoryTTL ) StopGCol () {
121+ if r .gcTicker != nil {
122+ r .Lock ()
123+ r .gcTicker .Stop ()
124+ r .gcTicker = nil
125+ close (r .done )
126+ r .done = nil
127+ r .Unlock ()
128+ }
129+ }
You can’t perform that action at this time.
0 commit comments