New creates a new memory cache with the given configuration.
(config Config)
| 74 | |
| 75 | // New creates a new memory cache with the given configuration. |
| 76 | func New(config Config) *Cache { |
| 77 | c := &Cache{ |
| 78 | config: config, |
| 79 | stopChan: make(chan struct{}), |
| 80 | closedChan: make(chan struct{}), |
| 81 | } |
| 82 | |
| 83 | go c.cleanupLoop() |
| 84 | return c |
| 85 | } |
| 86 | |
| 87 | // NewDefault creates a new memory cache with default configuration. |
| 88 | func NewDefault() *Cache { |