lookup checks for the regular expression in the cache in a synchronized manner, returning it if it exists.
(key RegexpCacheKey)
| 101 | // lookup checks for the regular expression in the cache in a |
| 102 | // synchronized manner, returning it if it exists. |
| 103 | func (rc *RegexpCache) lookup(key RegexpCacheKey) *regexp.Regexp { |
| 104 | rc.mu.Lock() |
| 105 | defer rc.mu.Unlock() |
| 106 | v, ok := rc.cache.Get(key) |
| 107 | if !ok { |
| 108 | return nil |
| 109 | } |
| 110 | return v.(*regexp.Regexp) |
| 111 | } |
| 112 | |
| 113 | // update invalidates the regular expression for the given pattern. |
| 114 | // If a new regular expression is passed in, it is inserted into the cache. |
no test coverage detected