Get returns the requested item, or sets exists=false. Get is completely threadsafe as long as you treat all items as immutable.
(obj interface{})
| 192 | // Get returns the requested item, or sets exists=false. |
| 193 | // Get is completely threadsafe as long as you treat all items as immutable. |
| 194 | func (c *cache) Get(obj interface{}) (item interface{}, exists bool, err error) { |
| 195 | key, err := c.keyFunc(obj) |
| 196 | if err != nil { |
| 197 | return nil, false, KeyError{obj, err} |
| 198 | } |
| 199 | return c.GetByKey(key) |
| 200 | } |
| 201 | |
| 202 | // GetByKey returns the request item, or exists=false. |
| 203 | // GetByKey is completely threadsafe as long as you treat all items as immutable. |