type ExpirationCache … type ExpirationPolicy … type TTLPolicy … // IsExpired returns true if the given object is older than the ttl, or it can't // determine its age. func (p *TTLPolicy) IsExpired(obj *TimestampedEntry) bool { … } type TimestampedEntry … // getTimestampedEntry returns the TimestampedEntry stored under the given key. func (c *ExpirationCache) getTimestampedEntry(key string) (*TimestampedEntry, bool) { … } // getOrExpire retrieves the object from the TimestampedEntry if and only if it hasn't // already expired. It holds a write lock across deletion. func (c *ExpirationCache) getOrExpire(key string) (interface{ … } // GetByKey returns the item stored under the key, or sets exists=false. func (c *ExpirationCache) GetByKey(key string) (interface{ … } // Get returns unexpired items. It purges the cache of expired items in the // process. func (c *ExpirationCache) Get(obj interface{ … } // List retrieves a list of unexpired items. It purges the cache of expired // items in the process. func (c *ExpirationCache) List() []interface{ … } // ListKeys returns a list of all keys in the expiration cache. func (c *ExpirationCache) ListKeys() []string { … } // Add timestamps an item and inserts it into the cache, overwriting entries // that might exist under the same key. func (c *ExpirationCache) Add(obj interface{ … } // Update has not been implemented yet for lack of a use case, so this method // simply calls `Add`. This effectively refreshes the timestamp. func (c *ExpirationCache) Update(obj interface{ … } // Delete removes an item from the cache. func (c *ExpirationCache) Delete(obj interface{ … } // Replace will convert all items in the given list to TimestampedEntries // before attempting the replace operation. The replace operation will // delete the contents of the ExpirationCache `c`. func (c *ExpirationCache) Replace(list []interface{ … } // Resync is a no-op for one of these func (c *ExpirationCache) Resync() error { … } // NewTTLStore creates and returns a ExpirationCache with a TTLPolicy func NewTTLStore(keyFunc KeyFunc, ttl time.Duration) Store { … } // NewExpirationStore creates and returns a ExpirationCache for a given policy func NewExpirationStore(keyFunc KeyFunc, expirationPolicy ExpirationPolicy) Store { … }