Lookup returns the stored response for the given question and a boolean indicating whether the question was found. When the cache is file-backed and the file has been modified since our last load (typically by another process), the in-memory state is reloaded before the lookup so cross-process writ
(question string)
| 112 | // our last load (typically by another process), the in-memory state is |
| 113 | // reloaded before the lookup so cross-process writes are visible. |
| 114 | func (c *Cache) Lookup(question string) (string, bool) { |
| 115 | c.maybeReload() |
| 116 | key := c.normalize(question) |
| 117 | c.mu.RLock() |
| 118 | defer c.mu.RUnlock() |
| 119 | resp, ok := c.entries[key] |
| 120 | return resp, ok |
| 121 | } |
| 122 | |
| 123 | // Store records the response for the given question, replacing any |
| 124 | // existing entry with the same normalized key. Storing the same |