Get retrieves the value and error for the given key from the cache. It returns the value and true if found, or an empty string and false otherwise.
(key string)
| 48 | // Get retrieves the value and error for the given key from the cache. |
| 49 | // It returns the value and true if found, or an empty string and false otherwise. |
| 50 | func (c *PolicyCache) Get(key string) (string, bool) { |
| 51 | actual, ok := c.Data.Load(key) |
| 52 | if !ok { |
| 53 | return "", ok |
| 54 | } |
| 55 | entry, ok := actual.(*cacheEntry) |
| 56 | if !ok { |
| 57 | return "", ok |
| 58 | } |
| 59 | return entry.value, ok |
| 60 | } |
| 61 | |
| 62 | // Set manually sets the value for a given key in the cache. |
| 63 | // It overwrites any existing value and error. |
no outgoing calls