{"modulePath":"github.com/dockerstack/kubernetes","version":"v0.20.1-0.20150627061651-1c0b765df6da","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cache\n\nPackage cache is a client-side caching mechanism. It is useful for reducing the number of server calls you'd otherwise need to make. Reflector watches a server and updates a Store. Two stores are provided; one that simply caches objects (for example, to allow a scheduler to list currently available minions), and one that additionally acts as a FIFO queue (for example, to allow a scheduler to process incoming pods).\n\n## Variables\n\n```go\nvar (\n\t// ErrZeroLengthDeltasObject is returned in a KeyError if a Deltas\n\t// object with zero length is encountered (should be impossible,\n\t// even if such an object is accidentally produced by a DeltaCompressor--\n\t// but included for completeness).\n\tErrZeroLengthDeltasObject = errors.New(\"0 length Deltas object; can't get key\")\n)\n```\n\n## Functions\n\n```go\nfunc MetaNamespaceIndexFunc(obj interface{}) (string, error)\n```\nMetaNamespaceIndexFunc is a default index function that indexes based on an object's namespace\n\n```go\nfunc MetaNamespaceKeyFunc(obj interface{}) (string, error)\n```\nMetaNamespaceKeyFunc is a convenient default KeyFunc which knows how to make keys for API objects which implement meta.Interface. The key uses the format \\\u003cnamespace\u003e/\\\u003cname\u003e unless \\\u003cnamespace\u003e is empty, then it's just \\\u003cname\u003e.\n\nTODO: replace key-as-string with a key-as-struct so that this packing/unpacking won't be necessary.\n\n```go\nfunc NewNamespaceKeyedIndexerAndReflector(lw ListerWatcher, expectedType interface{}, resyncPeriod time.Duration) (indexer Indexer, reflector *Reflector)\n```\nNewNamespaceKeyedIndexerAndReflector creates an Indexer and a Reflector The indexer is configured to key on namespace\n\n```go\nfunc SplitMetaNamespaceKey(key string) (namespace, name string, err error)\n```\nSplitMetaNamespaceKey returns the namespace and name that MetaNamespaceKeyFunc encoded into key.\n\nTODO: replace key-as-string with a key-as-struct so that this packing/unpacking won't be necessary.\n\n## Types\n\n```go\ntype DeletedFinalStateUnknown struct {\n\tKey string\n\tObj interface{}\n}\n```\nDeletedFinalStateUnknown is placed into a DeltaFIFO in the case where an object was deleted but the watch deletion event was missed. In this case we don't know the final \"resting\" state of the object, so there's a chance the included \\`Obj\\` is stale.\n\n```go\ntype Delta struct {\n\tType   DeltaType\n\tObject interface{}\n}\n```\nDelta is the type stored by a DeltaFIFO. It tells you what change happened, and the object's state after\\* that change.\n\n\\[\\*] Unless the change is a deletion, and then you'll get the final\n\n\tstate of the object before it was deleted.\n\n```go\ntype DeltaCompressor interface {\n\tCompress(Deltas) Deltas\n}\n```\nDeltaCompressor is an algorithm that removes redundant changes.\n\n```go\ntype DeltaCompressorFunc func(Deltas) Deltas\n```\nDeltaCompressorFunc should remove redundant changes; but changes that are redundant depend on one's desired semantics, so this is an injectable function.\n\nDeltaCompressorFunc adapts a raw function to be a DeltaCompressor.\n\n```go\nfunc (dc DeltaCompressorFunc) Compress(d Deltas) Deltas\n```\nCompress just calls dc.\n\n```go\ntype DeltaFIFO struct {\n\t// contains filtered or unexported fields\n}\n```\nDeltaFIFO is like FIFO, but allows you to process deletes.\n\nDeltaFIFO is a producer-consumer queue, where a Reflector is intended to be the producer, and the consumer is whatever calls the Pop() method.\n\nDeltaFIFO solves this use case:\n\n  - You want to process every object change (delta) at most once.\n  - When you process an object, you want to see everything that's happened to it since you last processed it.\n  - You want to process the deletion of objects.\n  - You might want to periodically reprocess objects.\n\nDeltaFIFO's Pop(), Get(), and GetByKey() methods return interface{} to satisfy the Store/Queue interfaces, but it will always return an object of type Deltas.\n\nA note on threading: If you call Pop() in parallel from multiple threads, you could end up with multiple threads processing slightly different versions of the same object.\n\nA note on the KeyLister used by the DeltaFIFO: It's main purpose is to list keys that are \"known\", for the puspose of figuring out which items have been deleted when Replace() is called. If the given KeyLister also satisfies the KeyGetter interface, the deleted objet will be included in the DeleteFinalStateUnknown markers. These objects could be stale.\n\nYou may provide a function to compress deltas (e.g., represent a series of Updates as a single Update).\n\n```go\nfunc NewDeltaFIFO(keyFunc KeyFunc, compressor DeltaCompressor, knownObjectKeys KeyLister) *DeltaFIFO\n```\nNewDeltaFIFO returns a Store which can be used process changes to items.\n\nkeyFunc is used to figure out what key an object should have. (It's exposed in the returned DeltaFIFO's KeyOf() method, with bonus features.)\n\n'compressor' may compress as many or as few items as it wants (including returning an empty slice), but it should do what it does quickly since it is called while the queue is locked. 'compressor' may be nil if you don't want any delta compression.\n\n'keyLister' is expected to return a list of keys that the consumer of this queue \"knows about\". It is used to decide which items are missing when Replace() is called; 'Deleted' deltas are produced for these items. It may be nil if you don't need to detect all deletions. TODO: consider merging keyLister with this object, tracking a list of\n\n\t\"known\" keys when Pop() is called. Have to think about how that\n\taffects error retrying.\n\nAlso see the comment on DeltaFIFO.\n\n```go\nfunc (f *DeltaFIFO) Add(obj interface{}) error\n```\nAdd inserts an item, and puts it in the queue. The item is only enqueued if it doesn't already exist in the set.\n\n```go\nfunc (f *DeltaFIFO) AddIfNotPresent(obj interface{}) error\n```\nAddIfNotPresent inserts an item, and puts it in the queue. If the item is already present in the set, it is neither enqueued nor added to the set.\n\nThis is useful in a single producer/consumer scenario so that the consumer can safely retry items without contending with the producer and potentially enqueueing stale items.\n\nImportant: obj must be a Deltas (the output of the Pop() function). Yes, this is different from the Add/Update/Delete functions.\n\n```go\nfunc (f *DeltaFIFO) Delete(obj interface{}) error\n```\nDelete is just like Add, but makes an Deleted Delta.\n\n```go\nfunc (f *DeltaFIFO) Get(obj interface{}) (item interface{}, exists bool, err error)\n```\nGet returns the complete list of deltas for the requested item, or sets exists=false. You should treat the items returned inside the deltas as immutable.\n\n```go\nfunc (f *DeltaFIFO) GetByKey(key string) (item interface{}, exists bool, err error)\n```\nGetByKey returns the complete list of deltas for the requested item, setting exists=false if that list is empty. You should treat the items returned inside the deltas as immutable.\n\n```go\nfunc (f *DeltaFIFO) KeyOf(obj interface{}) (string, error)\n```\nKeyOf exposes f's keyFunc, but also detects the key of a Deltas object or DeletedFinalStateUnknown objects.\n\n```go\nfunc (f *DeltaFIFO) List() []interface{}\n```\nList returns a list of all the items; it returns the object from the most recent Delta. You should treat the items returned inside the deltas as immutable.\n\n```go\nfunc (f *DeltaFIFO) ListKeys() []string\n```\nListKeys returns a list of all the keys of the objects currently in the FIFO.\n\n```go\nfunc (f *DeltaFIFO) Pop() interface{}\n```\nPop blocks until an item is added to the queue, and then returns it.  If multiple items are ready, they are returned in the order in which they were added/updated. The item is removed from the queue (and the store) before it is returned, so if you don't succesfully process it, you need to add it back with AddIfNotPresent().\n\nPop returns a 'Deltas', which has a complete list of all the things that happened to the object (deltas) while it was sitting in the queue.\n\n```go\nfunc (f *DeltaFIFO) Replace(list []interface{}) error\n```\nReplace will delete the contents of 'f', using instead the given map. 'f' takes ownership of the map, you should not reference the map again after calling this function. f's queue is reset, too; upon return, it will contain the items in the map, in no particular order.\n\n```go\nfunc (f *DeltaFIFO) Update(obj interface{}) error\n```\nUpdate is just like Add, but makes an Updated Delta.\n\n```go\ntype DeltaType string\n```\nDeltaType is the type of a change (addition, deletion, etc)\n\n```go\nconst (\n\tAdded   DeltaType = \"Added\"\n\tUpdated DeltaType = \"Updated\"\n\tDeleted DeltaType = \"Deleted\"\n\t// The other types are obvious. You'll get Sync deltas when:\n\t//  * A watch expires/errors out and a new list/watch cycle is started.\n\t//  * You've turned on periodic syncs.\n\t// (Anything that trigger's DeltaFIFO's Replace() method.)\n\tSync DeltaType = \"Sync\"\n)\n```\n\n```go\ntype Deltas []Delta\n```\nDeltas is a list of one or more 'Delta's to an individual object. The oldest delta is at index 0, the newest delta is the last one.\n\n```go\nfunc (d Deltas) Newest() *Delta\n```\nNewest is a convenience function that returns the newest delta, or nil if there are no deltas.\n\n```go\nfunc (d Deltas) Oldest() *Delta\n```\nOldest is a convenience function that returns the oldest delta, or nil if there are no deltas.\n\n```go\ntype Enumerator interface {\n\tLen() int\n\tGet(index int) (object interface{})\n}\n```\nEnumerator should be able to return the list of objects to be synced with one object at a time.\n\n```go\ntype ExpirationCache struct {\n\t// contains filtered or unexported fields\n}\n```\nExpirationCache implements the store interface\n\n 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\n 2. Expiration happens lazily on read based on the expiration policy\n 3. Time-stamps are stripped off unexpired entries before return\n\n```go\nfunc (c *ExpirationCache) Add(obj interface{}) error\n```\nAdd timestamps an item and inserts it into the cache, overwriting entries that might exist under the same key.\n\n```go\nfunc (c *ExpirationCache) Delete(obj interface{}) error\n```\nDelete removes an item from the cache.\n\n```go\nfunc (c *ExpirationCache) Get(obj interface{}) (interface{}, bool, error)\n```\nGet returns unexpired items. It purges the cache of expired items in the process.\n\n```go\nfunc (c *ExpirationCache) GetByKey(key string) (interface{}, bool, error)\n```\nGetByKey returns the item stored under the key, or sets exists=false.\n\n```go\nfunc (c *ExpirationCache) List() []interface{}\n```\nList retrieves a list of unexpired items. It purges the cache of expired items in the process.\n\n```go\nfunc (c *ExpirationCache) ListKeys() []string\n```\nListKeys returns a list of all keys in the expiration cache.\n\n```go\nfunc (c *ExpirationCache) Replace(list []interface{}) error\n```\nReplace 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\\`.\n\n```go\nfunc (c *ExpirationCache) Update(obj interface{}) error\n```\nUpdate has not been implemented yet for lack of a use case, so this method simply calls \\`Add\\`. This effectively refreshes the timestamp.\n\n```go\ntype ExpirationPolicy interface {\n\tIsExpired(obj *timestampedEntry) bool\n}\n```\nExpirationPolicy dictates when an object expires. Currently only abstracted out so unittests don't rely on the system clock.\n\n```go\ntype ExplicitKey string\n```\nExplicitKey can be passed to MetaNamespaceKeyFunc if you have the key for the object but not the object itself.\n\n```go\ntype FIFO struct {\n\t// contains filtered or unexported fields\n}\n```\nFIFO receives adds and updates from a Reflector, and puts them in a queue for FIFO order processing. If multiple adds/updates of a single item happen while an item is in the queue before it has been processed, it will only be processed once, and when it is processed, the most recent version will be processed. This can't be done with a channel.\n\nFIFO solves this use case:\n\n  - You want to process every object (exactly) once.\n  - You want to process the most recent version of the object when you process it.\n  - You do not want to process deleted objects, they should be removed from the queue.\n  - You do not want to periodically reprocess objects.\n\nCompare with DeltaFIFO for other use cases.\n\n```go\nfunc NewFIFO(keyFunc KeyFunc) *FIFO\n```\nNewFIFO returns a Store which can be used to queue up items to process.\n\n```go\nfunc (f *FIFO) Add(obj interface{}) error\n```\nAdd inserts an item, and puts it in the queue. The item is only enqueued if it doesn't already exist in the set.\n\n```go\nfunc (f *FIFO) AddIfNotPresent(obj interface{}) error\n```\nAddIfNotPresent inserts an item, and puts it in the queue. If the item is already present in the set, it is neither enqueued nor added to the set.\n\nThis is useful in a single producer/consumer scenario so that the consumer can safely retry items without contending with the producer and potentially enqueueing stale items.\n\n```go\nfunc (f *FIFO) Delete(obj interface{}) error\n```\nDelete removes an item. It doesn't add it to the queue, because this implementation assumes the consumer only cares about the objects, not the order in which they were created/added.\n\n```go\nfunc (f *FIFO) Get(obj interface{}) (item interface{}, exists bool, err error)\n```\nGet returns the requested item, or sets exists=false.\n\n```go\nfunc (f *FIFO) GetByKey(key string) (item interface{}, exists bool, err error)\n```\nGetByKey returns the requested item, or sets exists=false.\n\n```go\nfunc (f *FIFO) List() []interface{}\n```\nList returns a list of all the items.\n\n```go\nfunc (f *FIFO) ListKeys() []string\n```\nListKeys returns a list of all the keys of the objects currently in the FIFO.\n\n```go\nfunc (f *FIFO) Pop() interface{}\n```\nPop waits until an item is ready and returns it. If multiple items are ready, they are returned in the order in which they were added/updated. The item is removed from the queue (and the store) before it is returned, so if you don't succesfully process it, you need to add it back with AddIfNotPresent().\n\n```go\nfunc (f *FIFO) Replace(list []interface{}) error\n```\nReplace will delete the contents of 'f', using instead the given map. 'f' takes ownership of the map, you should not reference the map again after calling this function. f's queue is reset, too; upon return, it will contain the items in the map, in no particular order.\n\n```go\nfunc (f *FIFO) Update(obj interface{}) error\n```\nUpdate is the same as Add in this implementation.\n\n```go\ntype FakeExpirationPolicy struct {\n\tNeverExpire     util.StringSet\n\tRetrieveKeyFunc KeyFunc\n}\n```\n\n```go\nfunc (p *FakeExpirationPolicy) IsExpired(obj *timestampedEntry) bool\n```\n\n```go\ntype GetFunc func() (Enumerator, error)\n```\nGetFunc should return an enumerator that you wish the Poller to proccess.\n\n```go\ntype Index map[string]util.StringSet\n```\nIndex maps the indexed value to a set of keys in the store that match on that value\n\n```go\ntype IndexFunc func(obj interface{}) (string, error)\n```\nIndexFunc knows how to provide an indexed value for an object.\n\n```go\ntype Indexer interface {\n\tStore\n\t// Retrieve list of objects that match on the named indexing function\n\tIndex(indexName string, obj interface{}) ([]interface{}, error)\n}\n```\nIndexer is a storage interface that lets you list objects using multiple indexing functions\n\n```go\nfunc NewIndexer(keyFunc KeyFunc, indexers Indexers) Indexer\n```\nNewIndexer returns an Indexer implemented simply with a map and a lock.\n\n```go\ntype Indexers map[string]IndexFunc\n```\nIndexers maps a name to a IndexFunc\n\n```go\ntype Indices map[string]Index\n```\nIndices maps a name to an Index\n\n```go\ntype KeyError struct {\n\tObj interface{}\n\tErr error\n}\n```\nKeyError will be returned any time a KeyFunc gives an error; it includes the object at fault.\n\n```go\nfunc (k KeyError) Error() string\n```\nError gives a human-readable description of the error.\n\n```go\ntype KeyFunc func(obj interface{}) (string, error)\n```\nKeyFunc knows how to make a key from an object. Implementations should be deterministic.\n\n```go\ntype KeyGetter interface {\n\tGetByKey(key string) (interface{}, bool, error)\n}\n```\nA KeyGetter is anything that knows how to get the value stored under a given key.\n\n```go\ntype KeyLister interface {\n\tListKeys() []string\n}\n```\nA KeyLister is anything that knows how to list its keys.\n\n```go\ntype ListFunc func() (runtime.Object, error)\n```\nListFunc knows how to list resources\n\n```go\ntype ListWatch struct {\n\tListFunc  ListFunc\n\tWatchFunc WatchFunc\n}\n```\nListWatch knows how to list and watch a set of apiserver resources.  It satisfies the ListerWatcher interface. It is a convenience function for users of NewReflector, etc. ListFunc and WatchFunc must not be nil\n\n```go\nfunc NewListWatchFromClient(c *client.Client, resource string, namespace string, fieldSelector fields.Selector) *ListWatch\n```\nNewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.\n\n```go\nfunc (lw *ListWatch) List() (runtime.Object, error)\n```\nList a set of apiserver resources\n\n```go\nfunc (lw *ListWatch) Watch(resourceVersion string) (watch.Interface, error)\n```\nWatch a set of apiserver resources\n\n```go\ntype ListerWatcher interface {\n\t// List should return a list type object; the Items field will be extracted, and the\n\t// ResourceVersion field will be used to start the watch in the right place.\n\tList() (runtime.Object, error)\n\t// Watch should begin a watch at the specified version.\n\tWatch(resourceVersion string) (watch.Interface, error)\n}\n```\nListerWatcher is any object that knows how to perform an initial list and start a watch on a resource.\n\n```go\ntype Poller struct {\n\t// contains filtered or unexported fields\n}\n```\nPoller is like Reflector, but it periodically polls instead of watching. This is intended to be a workaround for api objects that don't yet support watching.\n\n```go\nfunc NewPoller(getFunc GetFunc, period time.Duration, store Store) *Poller\n```\nNewPoller constructs a new poller. Note that polling probably doesn't make much sense to use along with the FIFO queue. The returned Poller will call getFunc and sync the objects in 'store' with the returned Enumerator, waiting 'period' between each call. It probably only makes sense to use a poller if you're treating the store as read-only.\n\n```go\nfunc (p *Poller) Run()\n```\nRun begins polling. It starts a goroutine and returns immediately.\n\n```go\nfunc (p *Poller) RunUntil(stopCh \u003c-chan struct{})\n```\nRunUntil begins polling. It starts a goroutine and returns immediately. It will stop when the stopCh is closed.\n\n```go\ntype Queue interface {\n\tStore\n\n\t// Pop blocks until it has something to return.\n\tPop() interface{}\n\n\t// AddIfNotPresent adds a value previously\n\t// returned by Pop back into the queue as long\n\t// as nothing else (presumably more recent)\n\t// has since been added.\n\tAddIfNotPresent(interface{}) error\n}\n```\nQueue is exactly like a Store, but has a Pop() method too.\n\n```go\ntype Reflector struct {\n\t// contains filtered or unexported fields\n}\n```\nReflector watches a specified resource and causes all changes to be reflected in the given store.\n\n```go\nfunc NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector\n```\nNewReflector creates a new Reflector object which will keep the given store up to date with the server's contents for the given resource. Reflector promises to only put things in the store that have the type of expectedType. If resyncPeriod is non-zero, then lists will be executed after every resyncPeriod, so that you can use reflectors to periodically process everything as well as incrementally processing the things that change.\n\n```go\nfunc (r *Reflector) LastSyncResourceVersion() string\n```\nLastSyncResourceVersion is the resource version observed when last sync with the underlying store The value returned is not synchronized with access to the underlying store and is not thread-safe\n\n```go\nfunc (r *Reflector) Run()\n```\nRun starts a watch and handles watch events. Will restart the watch if it is closed. Run starts a goroutine and returns immediately.\n\n```go\nfunc (r *Reflector) RunUntil(stopCh \u003c-chan struct{})\n```\nRunUntil starts a watch and handles watch events. Will restart the watch if it is closed. RunUntil starts a goroutine and returns immediately. It will exit when stopCh is closed.\n\n```go\ntype Store interface {\n\tAdd(obj interface{}) error\n\tUpdate(obj interface{}) error\n\tDelete(obj interface{}) error\n\tList() []interface{}\n\tListKeys() []string\n\tGet(obj interface{}) (item interface{}, exists bool, err error)\n\tGetByKey(key string) (item interface{}, exists bool, err error)\n\n\t// Replace will delete the contents of the store, using instead the\n\t// given list. Store takes ownership of the list, you should not reference\n\t// it after calling this function.\n\tReplace([]interface{}) error\n}\n```\nStore is a generic object storage interface. Reflector knows how to watch a server and update a store. A generic store is provided, which allows Reflector to be used as a local caching system, and an LRU store, which allows Reflector to work like a queue of items yet to be processed.\n\nStore makes no assumptions about stored object identity; it is the responsibility of a Store implementation to provide a mechanism to correctly key objects and to define the contract for obtaining objects by some arbitrary key type.\n\n```go\nfunc NewFakeExpirationStore(keyFunc KeyFunc, deletedKeys chan\u003c- string, expirationPolicy ExpirationPolicy, cacheClock util.Clock) Store\n```\n\n```go\nfunc NewStore(keyFunc KeyFunc) Store\n```\nNewStore returns a Store implemented simply with a map and a lock.\n\n```go\nfunc NewTTLStore(keyFunc KeyFunc, ttl time.Duration) Store\n```\nNewTTLStore creates and returns a ExpirationCache with a TTLPolicy\n\n```go\ntype StoreToControllerLister struct {\n\tStore\n}\n```\nStoreToControllerLister gives a store List and Exists methods. The store must contain only ReplicationControllers.\n\n```go\nfunc (s *StoreToControllerLister) Exists(controller *api.ReplicationController) (bool, error)\n```\nExists checks if the given rc exists in the store.\n\n```go\nfunc (s *StoreToControllerLister) GetPodControllers(pod *api.Pod) (controllers []api.ReplicationController, err error)\n```\nGetPodControllers returns a list of controllers managing a pod. Returns an error only if no matching controllers are found.\n\n```go\nfunc (s *StoreToControllerLister) List() (controllers []api.ReplicationController, err error)\n```\nStoreToControllerLister lists all controllers in the store. TODO: converge on the interface in pkg/client\n\n```go\ntype StoreToNodeLister struct {\n\tStore\n}\n```\nStoreToNodeLister makes a Store have the List method of the client.NodeInterface The Store must contain (only) Nodes.\n\n```go\nfunc (s *StoreToNodeLister) GetNodeInfo(id string) (*api.Node, error)\n```\nTODO Move this back to scheduler as a helper function that takes a Store, rather than a method of StoreToNodeLister. GetNodeInfo returns cached data for the minion 'id'.\n\n```go\nfunc (s *StoreToNodeLister) List() (machines api.NodeList, err error)\n```\n\n```go\nfunc (s *StoreToNodeLister) NodeCondition(conditionType api.NodeConditionType, conditionStatus api.ConditionStatus) storeToNodeConditionLister\n```\nNodeCondition returns a storeToNodeConditionLister\n\n```go\ntype StoreToPodLister struct {\n\tStore\n}\n```\nStoreToPodLister makes a Store have the List method of the client.PodInterface The Store must contain (only) Pods.\n\nExample: s := cache.NewStore() lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: \"pods\"} r := cache.NewReflector(lw, \u0026api.Pod{}, s).Run() l := StoreToPodLister{s} l.List()\n\n```go\nfunc (s *StoreToPodLister) Exists(pod *api.Pod) (bool, error)\n```\nExists returns true if a pod matching the namespace/name of the given pod exists in the store.\n\n```go\nfunc (s *StoreToPodLister) List(selector labels.Selector) (pods []*api.Pod, err error)\n```\nPlease note that selector is filtering among the pods that have gotten into the store; there may have been some filtering that already happened before that.\n\nTODO: converge on the interface in pkg/client.\n\n```go\nfunc (s *StoreToPodLister) Pods(namespace string) storePodsNamespacer\n```\nPods is taking baby steps to be more like the api in pkg/client\n\n```go\ntype StoreToServiceLister struct {\n\tStore\n}\n```\nStoreToServiceLister makes a Store that has the List method of the client.ServiceInterface The Store must contain (only) Services.\n\n```go\nfunc (s *StoreToServiceLister) GetPodServices(pod *api.Pod) (services []api.Service, err error)\n```\nTODO: Move this back to scheduler as a helper function that takes a Store, rather than a method of StoreToServiceLister.\n\n```go\nfunc (s *StoreToServiceLister) List() (services api.ServiceList, err error)\n```\n\n```go\ntype TTLPolicy struct {\n\t//\t \u003e0: Expire entries with an age \u003e ttl\n\t//\t\u003c=0: Don't expire any entry\n\tTtl time.Duration\n\n\t// Clock used to calculate ttl expiration\n\tClock util.Clock\n}\n```\nTTLPolicy implements a ttl based ExpirationPolicy.\n\n```go\nfunc (p *TTLPolicy) IsExpired(obj *timestampedEntry) bool\n```\nIsExpired returns true if the given object is older than the ttl, or it can't determine its age.\n\n```go\ntype ThreadSafeStore interface {\n\tAdd(key string, obj interface{})\n\tUpdate(key string, obj interface{})\n\tDelete(key string)\n\tGet(key string) (item interface{}, exists bool)\n\tList() []interface{}\n\tListKeys() []string\n\tReplace(map[string]interface{})\n\tIndex(indexName string, obj interface{}) ([]interface{}, error)\n}\n```\nThreadSafeStore is an interface that allows concurrent access to a storage backend. TL;DR caveats: you must not modify anything returned by Get or List as it will break the indexing feature in addition to not being thread safe.\n\nThe guarantees of thread safety provided by List/Get are only valid if the caller treats returned items as read-only. For example, a pointer inserted in the store through \\`Add\\` will be returned as is by \\`Get\\`. Multiple clients might invoke \\`Get\\` on the same key and modify the pointer in a non-thread-safe way. Also note that modifying objects stored by the indexers (if any) will \\*not\\* automatically lead to a re-index. So it's not a good idea to directly modify the objects returned by Get/List, in general.\n\n```go\nfunc NewThreadSafeStore(indexers Indexers, indices Indices) ThreadSafeStore\n```\n\n```go\ntype UndeltaStore struct {\n\tStore\n\tPushFunc func([]interface{})\n}\n```\nUndeltaStore listens to incremental updates and sends complete state on every change. It implements the Store interface so that it can receive a stream of mirrored objects from Reflector.  Whenever it receives any complete (Store.Replace) or incremental change (Store.Add, Store.Update, Store.Delete), it sends the complete state by calling PushFunc. It is thread-safe.  It guarantees that every change (Add, Update, Replace, Delete) results in one call to PushFunc, but sometimes PushFunc may be called twice with the same values. PushFunc should be thread safe.\n\n```go\nfunc NewUndeltaStore(pushFunc func([]interface{}), keyFunc KeyFunc) *UndeltaStore\n```\nNewUndeltaStore returns an UndeltaStore implemented with a Store.\n\n```go\nfunc (u *UndeltaStore) Add(obj interface{}) error\n```\n\n```go\nfunc (u *UndeltaStore) Delete(obj interface{}) error\n```\n\n```go\nfunc (u *UndeltaStore) Replace(list []interface{}) error\n```\n\n```go\nfunc (u *UndeltaStore) Update(obj interface{}) error\n```\n\n```go\ntype WatchFunc func(resourceVersion string) (watch.Interface, error)\n```\nWatchFunc knows how to watch resources\n\n","path":"github.com/dockerstack/kubernetes/pkg/client/cache","name":"cache","synopsis":"Package cache is a client-side caching mechanism.","isRedistributable":true}
