Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RegexpCache ¶
type RegexpCache struct { // Size is the maximum size of the cache Size int // contains filtered or unexported fields }
RegexpCache caches compilation of regular expressions. Except for modification of Size, it can be used concurrently.
Example ¶
// create a cache of size 2 cache := &RegexpCache{ Size: 2, } // compile 'hello' regexp first, err := cache.Compile("hello") fmt.Println(first, err) // compile 'world' regexp second, err := cache.Compile("world") fmt.Println(second, err) // compile 'hello' regexp again third, err := cache.Compile("hello") fmt.Println(third, err) // this is re-using the same regular expression fmt.Println(unsafe.Pointer(first) == unsafe.Pointer(third))
Output: hello <nil> world <nil> hello <nil> true
func (*RegexpCache) Compile ¶
func (rr *RegexpCache) Compile(src string) (exp *regexp.Regexp, err error)
Compile returns a (possibly cached) compiled version of src. When src is invalid it is never cached.
See regexp.Compile for description of regular expressions.
func (*RegexpCache) Reset ¶
func (rr *RegexpCache) Reset()
Reset removes all cached regular expressions
Click to show internal directories.
Click to hide internal directories.