get retrieves a cached suggestion if available
(input string)
| 49 | |
| 50 | // get retrieves a cached suggestion if available |
| 51 | func (c *keywordSuggestionCache) get(input string) (string, bool) { |
| 52 | c.mu.RLock() |
| 53 | defer c.mu.RUnlock() |
| 54 | result, ok := c.cache[input] |
| 55 | if ok { |
| 56 | atomic.AddUint64(&c.hits, 1) |
| 57 | } else { |
| 58 | atomic.AddUint64(&c.misses, 1) |
| 59 | } |
| 60 | return result, ok |
| 61 | } |
| 62 | |
| 63 | // set stores a suggestion in the cache |
| 64 | func (c *keywordSuggestionCache) set(input, suggestion string) { |