ExpirationCache implements the store interface 1. All entries are automatically time stamped on insert a. The key is computed based off the original item/keyFunc b. The value inserted under that key is the timestamped item 2. Expiration happens lazily on read based on the expiration policy a.
| 36 | // threadSafeStore because it takes a write lock every time it checks if |
| 37 | // an item has expired. |
| 38 | type ExpirationCache struct { |
| 39 | cacheStorage ThreadSafeStore |
| 40 | keyFunc KeyFunc |
| 41 | clock clock.Clock |
| 42 | expirationPolicy ExpirationPolicy |
| 43 | // expirationLock is a write lock used to guarantee that we don't clobber |
| 44 | // newly inserted objects because of a stale expiration timestamp comparison |
| 45 | expirationLock sync.Mutex |
| 46 | } |
| 47 | |
| 48 | // ExpirationPolicy dictates when an object expires. Currently only abstracted out |
| 49 | // so unittests don't rely on the system clock. |
nothing calls this directly
no outgoing calls
no test coverage detected