NewRegexpCache creates a new RegexpCache of the given size. The underlying cache internally uses a hash map, so lookups are cheap.
(size int)
| 34 | // The underlying cache internally uses a hash map, so lookups |
| 35 | // are cheap. |
| 36 | func NewRegexpCache(size int) *RegexpCache { |
| 37 | return &RegexpCache{ |
| 38 | cache: cache.NewUnorderedCache(cache.Config{ |
| 39 | Policy: cache.CacheLRU, |
| 40 | ShouldEvict: func(s int, key, value interface{}) bool { |
| 41 | return s > size |
| 42 | }, |
| 43 | }), |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // GetRegexp consults the cache for the regular expressions stored for |
| 48 | // the given key, compiling the key's pattern if it is not already |
no test coverage detected
searching dependent graphs…