github.com/TykTechnologies/tyk/regexp
Package regexp implmenets API of Go's native "regexp" but with caching results in memory
Package
Files: 11. Third party imports: 0. Imports from organisation: 0. Tests: 0. Benchmarks: 0.
Constants
const (
defaultCacheItemTTL = 60 * time.Second
defaultCacheCleanupInterval = 5 * time.Minute
maxKeySize = 1024
maxValueSize = 2048
)
Vars
var (
compileCache = newRegexpCache(defaultCacheItemTTL, true, regexp.Compile)
compilePOSIXCache = newRegexpCache(defaultCacheItemTTL, true, regexp.CompilePOSIX)
matchStringCache = newRegexpStrRetBoolCache(defaultCacheItemTTL, true)
matchCache = newRegexpByteRetBoolCache(defaultCacheItemTTL, true)
replaceAllStringCache = newRegexpStrStrRetStrCache(defaultCacheItemTTL, true)
replaceAllLiteralStringCache = newRegexpStrStrRetStrCache(defaultCacheItemTTL, true)
replaceAllStringFuncCache = newRegexpStrFuncRetStrCache(defaultCacheItemTTL, true)
findStringSubmatchCache = newRegexpStrRetSliceStrCache(defaultCacheItemTTL, true)
findAllStringCache = newRegexpStrIntRetSliceStrCache(defaultCacheItemTTL, true)
findAllStringSubmatchCache = newRegexpStrIntRetSliceSliceStrCache(defaultCacheItemTTL, true)
)
var keyBuilderPool = sync.Pool{
New: func() interface{} { return new(keyBuilder) },
}
Types
Regexp
Regexp is a wrapper around regexp.Regexp but with caching
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. | |
| FromCache |
|
No comment on field. |
type Regexp struct {
*regexp.Regexp
FromCache bool
}
cache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. | |
| isEnabled |
|
No comment on field. |
| ttl |
|
No comment on field. |
type cache struct {
*gocache.Cache
isEnabled bool
ttl time.Duration
}
keyBuilder
Combine logic of strings.Builder and bytes.Buffer. Allow to reuse builder with 0 allocs, as bytes.Buffer and also allow to get 0 alloc string representation as strings.Builder
| Field name | Field type | Comment |
|---|---|---|
| buf |
|
No comment on field. |
type keyBuilder struct {
buf []byte
}
regexpByteRetBoolCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpByteRetBoolCache struct {
*cache
}
regexpCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. | |
| noCacheFunc |
|
No comment on field. |
type regexpCache struct {
*cache
noCacheFunc func(string) (*regexp.Regexp, error)
}
regexpStrFuncRetStrCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrFuncRetStrCache struct {
*cache
}
regexpStrIntRetSliceSliceStrCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrIntRetSliceSliceStrCache struct {
*cache
}
regexpStrIntRetSliceStrCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrIntRetSliceStrCache struct {
*cache
}
regexpStrRetBoolCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrRetBoolCache struct {
*cache
}
regexpStrRetSliceStrCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrRetSliceStrCache struct {
*cache
}
regexpStrStrRetStrCache
This type doesn't have documentation.
| Field name | Field type | Comment |
|---|---|---|
|
No comment on field. |
type regexpStrStrRetStrCache struct {
*cache
}
Functions
func Compile
Compile does the same as regexp.Compile but returns cached *Regexp instead.
func Compile(expr string) (*Regexp, error) {
return compileCache.do(expr)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func CompilePOSIX
CompilePOSIX does the same as regexp.CompilePOSIX but returns cached *Regexp instead.
func CompilePOSIX(expr string) (*Regexp, error) {
return compilePOSIXCache.do(expr)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func Match
Match is the same as regexp.Match but returns cached result instead.
func Match(pattern string, b []byte) (matched bool, err error) {
re, err := Compile(pattern)
if err != nil {
return false, err
}
return re.Match(b), nil
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func MatchString
MatchString is the same as regexp.MatchString but returns cached result instead.
func MatchString(pattern string, s string) (matched bool, err error) {
re, err := Compile(pattern)
if err != nil {
return false, err
}
return re.MatchString(s), nil
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func MustCompile
MustCompile is the same as regexp.MustCompile but returns cached *Regexp instead.
func MustCompile(str string) *Regexp {
regexp, err := Compile(str)
if err != nil {
panic(`regexp: Compile(` + quote(str) + `): ` + err.Error())
}
return regexp
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func MustCompilePOSIX
MustCompilePOSIX is the same as regexp.MustCompilePOSIX but returns cached *Regexp instead.
func MustCompilePOSIX(str string) *Regexp {
regexp, err := CompilePOSIX(str)
if err != nil {
panic(`regexp: CompilePOSIX(` + quote(str) + `): ` + err.Error())
}
return regexp
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func QuoteMeta
QuoteMeta is the same as regexp.QuoteMeta but returns cached result instead.
func QuoteMeta(s string) string {
// TODO: add cache for QuoteMeta
return regexp.QuoteMeta(s)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func ResetCache
ResetCache resets cache to initial state
func ResetCache(ttl time.Duration, isEnabled bool) {
if ttl == 0 {
ttl = defaultCacheItemTTL
}
compileCache.reset(ttl, isEnabled)
compilePOSIXCache.reset(ttl, isEnabled)
matchStringCache.reset(ttl, isEnabled)
matchCache.reset(ttl, isEnabled)
replaceAllStringCache.reset(ttl, isEnabled)
replaceAllLiteralStringCache.reset(ttl, isEnabled)
replaceAllStringFuncCache.reset(ttl, isEnabled)
findStringSubmatchCache.reset(ttl, isEnabled)
findAllStringCache.reset(ttl, isEnabled)
findAllStringSubmatchCache.reset(ttl, isEnabled)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) Copy
Copy returns a new Regexp object copied from re.
When using a Regexp in multiple goroutines, giving each goroutine its own copy helps to avoid lock contention.
func (re *Regexp) Copy() *Regexp {
reCopy := &Regexp{
FromCache: re.FromCache,
}
if re.Regexp != nil {
reCopy.Regexp = re.Regexp.Copy()
}
return reCopy
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) Expand
Expand is the same as regexp.Regexp.Expand but returns cached result instead.
func (re *Regexp) Expand(dst []byte, template []byte, src []byte, match []int) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for Expand
return re.Regexp.Expand(dst, template, src, match)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) ExpandString
ExpandString is the same as regexp.Regexp.ExpandString but returns cached result instead.
func (re *Regexp) ExpandString(dst []byte, template string, src string, match []int) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for ExpandString
return re.Regexp.ExpandString(dst, template, src, match)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) Find
Find is the same as regexp.Regexp.Find but returns cached result instead.
func (re *Regexp) Find(b []byte) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for Find
return re.Regexp.Find(b)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAll
FindAll is the same as regexp.Regexp.FindAll but returns cached result instead.
func (re *Regexp) FindAll(b []byte, n int) [][]byte {
if re.Regexp == nil {
return [][]byte{}
}
// TODO: add cache for FindAll
return re.Regexp.FindAll(b, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllIndex
FindAllIndex is the same as regexp.Regexp.FindAllIndex but returns cached result instead.
func (re *Regexp) FindAllIndex(b []byte, n int) [][]int {
if re.Regexp == nil {
return [][]int{}
}
// TODO: add cache for FindAllIndex
return re.Regexp.FindAllIndex(b, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllString
FindAllString is the same as regexp.Regexp.FindAllString but returns cached result instead.
func (re *Regexp) FindAllString(s string, n int) []string {
if re.Regexp == nil {
return []string{}
}
return findAllStringCache.do(re.Regexp, s, n, re.Regexp.FindAllString)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllStringIndex
FindAllStringIndex is the same as regexp.Regexp.FindAllStringIndex but returns cached result instead.
func (re *Regexp) FindAllStringIndex(s string, n int) [][]int {
if re.Regexp == nil {
return [][]int{}
}
// TODO: add cache for FindAllStringIndex
return re.Regexp.FindAllStringIndex(s, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllStringSubmatch
FindAllStringSubmatch is the same as regexp.Regexp.FindAllStringSubmatch but returns cached result instead.
func (re *Regexp) FindAllStringSubmatch(s string, n int) [][]string {
if re.Regexp == nil {
return [][]string{}
}
return findAllStringSubmatchCache.do(re.Regexp, s, n, re.Regexp.FindAllStringSubmatch)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllStringSubmatchIndex
FindAllStringSubmatchIndex is the same as regexp.Regexp.FindAllStringSubmatchIndex but returns cached result instead.
func (re *Regexp) FindAllStringSubmatchIndex(s string, n int) [][]int {
if re.Regexp == nil {
return [][]int{}
}
// TODO: add cache for FindAllStringSubmatchIndex
return re.Regexp.FindAllStringSubmatchIndex(s, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllSubmatch
FindAllSubmatch is the same as regexp.Regexp.FindAllSubmatch but returns cached result instead.
func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte {
if re.Regexp == nil {
return [][][]byte{}
}
// TODO: add cache for FindAllSubmatch
return re.Regexp.FindAllSubmatch(b, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindAllSubmatchIndex
FindAllSubmatchIndex is the same as regexp.Regexp.FindAllSubmatchIndex but returns cached result instead.
func (re *Regexp) FindAllSubmatchIndex(b []byte, n int) [][]int {
if re.Regexp == nil {
return [][]int{}
}
// TODO: add cache for FindAllSubmatchIndex
return re.Regexp.FindAllSubmatchIndex(b, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindIndex
FindIndex is the same as regexp.Regexp.FindIndex but returns cached result instead.
func (re *Regexp) FindIndex(b []byte) (loc []int) {
if re.Regexp == nil {
return
}
// TODO: add cache for FindIndex
return re.Regexp.FindIndex(b)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) FindReaderIndex
FindReaderIndex is the same as regexp.Regexp.FindReaderIndex (NO CACHE).
func (re *Regexp) FindReaderIndex(r io.RuneReader) (loc []int) {
if re.Regexp == nil {
return
}
return re.Regexp.FindReaderIndex(r)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) FindReaderSubmatchIndex
FindReaderSubmatchIndex is the same as regexp.Regexp.FindReaderSubmatchIndex (NO CACHE).
func (re *Regexp) FindReaderSubmatchIndex(r io.RuneReader) []int {
if re.Regexp == nil {
return []int{}
}
return re.Regexp.FindReaderSubmatchIndex(r)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindString
FindString is the same as regexp.Regexp.FindString but returns cached result instead.
func (re *Regexp) FindString(s string) string {
if re.Regexp == nil {
return ""
}
// TODO: add cache for FindString
return re.Regexp.FindString(s)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) FindStringIndex
FindStringIndex is the same as regexp.Regexp.FindStringIndex but returns cached result instead.
func (re *Regexp) FindStringIndex(s string) (loc []int) {
if re.Regexp == nil {
return
}
// TODO: add cache for FindStringIndex
return re.Regexp.FindStringIndex(s)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) FindStringSubmatch
FindStringSubmatch is the same as regexp.Regexp.FindStringSubmatch but returns cached result instead.
func (re *Regexp) FindStringSubmatch(s string) []string {
if re.Regexp == nil {
return []string{}
}
return findStringSubmatchCache.do(re.Regexp, s, re.Regexp.FindStringSubmatch)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindStringSubmatchIndex
FindStringSubmatchIndex is the same as regexp.Regexp.FindStringSubmatchIndex but returns cached result instead.
func (re *Regexp) FindStringSubmatchIndex(s string) []int {
if re.Regexp == nil {
return []int{}
}
// TODO: add cache for FindStringSubmatchIndex
return re.Regexp.FindStringSubmatchIndex(s)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindSubmatch
FindSubmatch is the same as regexp.Regexp.FindSubmatch but returns cached result instead.
func (re *Regexp) FindSubmatch(b []byte) [][]byte {
if re.Regexp == nil {
return [][]byte{}
}
// TODO: add cache for FindSubmatch
return re.Regexp.FindSubmatch(b)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) FindSubmatchIndex
FindSubmatchIndex is the same as regexp.Regexp.FindSubmatchIndex but returns cached result instead.
func (re *Regexp) FindSubmatchIndex(b []byte) []int {
if re.Regexp == nil {
return []int{}
}
// TODO: add cache for ExpandString
return re.Regexp.FindSubmatchIndex(b)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) LiteralPrefix
LiteralPrefix returns a literal string that must begin any match Calls regexp.Regexp.LiteralPrefix
func (re *Regexp) LiteralPrefix() (prefix string, complete bool) {
if re.Regexp == nil {
return "", false
}
return re.Regexp.LiteralPrefix()
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) Longest
Longest calls regexp.Regexp.Longest of wrapped regular expression
func (re *Regexp) Longest() {
if re.Regexp == nil {
re.Regexp.Longest()
}
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) Match
Match reports whether the Regexp matches the byte slice b.
func (re *Regexp) Match(b []byte) bool {
if re.Regexp == nil {
return false
}
return matchCache.do(re.Regexp, b, re.Regexp.Match)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) MatchReader
MatchReader reports whether the Regexp matches the text read by the RuneReader. Calls regexp.Regexp.MatchReader (NO CACHE)
func (re *Regexp) MatchReader(r io.RuneReader) bool {
if re.Regexp == nil {
return false
}
return re.Regexp.MatchReader(r)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) MatchString
MatchString reports whether the Regexp matches the string s.
func (re *Regexp) MatchString(s string) bool {
if re.Regexp == nil {
return false
}
return matchStringCache.do(re.Regexp, s, re.Regexp.MatchString)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) NumSubexp
NumSubexp returns result of regexp.Regexp.NumSubexp of wrapped regular expression.
func (re *Regexp) NumSubexp() int {
if re.Regexp == nil {
return 0
}
return re.Regexp.NumSubexp()
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) ReplaceAll
ReplaceAll is the same as regexp.Regexp.ReplaceAll but returns cached result instead.
func (re *Regexp) ReplaceAll(src, repl []byte) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for ReplaceAll
return re.Regexp.ReplaceAll(src, repl)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) ReplaceAllFunc
ReplaceAllFunc is the same as regexp.Regexp.ReplaceAllFunc but returns cached result instead.
func (re *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for ReplaceAllFunc
return re.Regexp.ReplaceAllFunc(src, repl)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) ReplaceAllLiteral
ReplaceAllLiteral is the same as regexp.Regexp.ReplaceAllLiteral but returns cached result instead.
func (re *Regexp) ReplaceAllLiteral(src, repl []byte) []byte {
if re.Regexp == nil {
return []byte{}
}
// TODO: add cache for ReplaceAllLiteral
return re.Regexp.ReplaceAllLiteral(src, repl)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) ReplaceAllLiteralString
ReplaceAllLiteralString is the same as regexp.Regexp.ReplaceAllLiteralString but returns cached result instead.
func (re *Regexp) ReplaceAllLiteralString(src, repl string) string {
if re.Regexp == nil {
return ""
}
return replaceAllLiteralStringCache.do(re.Regexp, src, repl, re.Regexp.ReplaceAllLiteralString)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) ReplaceAllString
ReplaceAllString is the same as regexp.Regexp.ReplaceAllString but returns cached result instead.
func (re *Regexp) ReplaceAllString(src, repl string) string {
if re.Regexp == nil {
return ""
}
return replaceAllStringCache.do(re.Regexp, src, repl, re.Regexp.ReplaceAllString)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) ReplaceAllStringFunc
ReplaceAllStringFunc is the same as regexp.Regexp.ReplaceAllStringFunc but returns cached result instead.
func (re *Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string {
if re.Regexp == nil {
return ""
}
return replaceAllStringFuncCache.do(re.Regexp, src, repl, re.Regexp.ReplaceAllStringFunc)
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) Split
Split is the same as regexp.Regexp.Split but returns cached result instead.
func (re *Regexp) Split(s string, n int) []string {
if re.Regexp == nil {
return []string{}
}
// TODO: add cache for Split
return re.Regexp.Split(s, n)
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*Regexp) String
String returns the source text used to compile the wrapped regular expression.
func (re *Regexp) String() string {
if re.Regexp == nil {
return ""
}
return re.Regexp.String()
}
Cognitive complexity: 2, Cyclomatic complexity: 2
func (*Regexp) SubexpNames
SubexpNames returns result of regexp.Regexp.SubexpNames of wrapped regular expression.
func (re *Regexp) SubexpNames() []string {
if re.Regexp == nil {
return []string{}
}
return re.Regexp.SubexpNames()
}
Cognitive complexity: 3, Cyclomatic complexity: 2
func (*keyBuilder) AppendBytes
func (kb *keyBuilder) AppendBytes(b []byte) *keyBuilder {
kb.buf = append(kb.buf, b...)
return kb
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) AppendInt
func (kb *keyBuilder) AppendInt(n int) *keyBuilder {
kb.buf = strconv.AppendInt(kb.buf, int64(n), 10)
return kb
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) AppendString
func (kb *keyBuilder) AppendString(s string) *keyBuilder {
kb.buf = append(kb.buf, s...)
return kb
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) Appendf
func (kb *keyBuilder) Appendf(format string, a ...interface{}) *keyBuilder {
fmt.Fprintf(kb, format, a...)
return kb
}
Cognitive complexity: 1, Cyclomatic complexity: 1
func (*keyBuilder) Key
Returns content of internal buffer, converted to string. Safe for using as key for storing item, immutable
func (kb *keyBuilder) Key() string {
return string(kb.buf)
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) Reset
Reset resets the keyBuilder to be empty.
func (kb *keyBuilder) Reset() *keyBuilder {
kb.buf = kb.buf[:0]
return kb
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) UnsafeKey
Returns string representation of internal buffer. Mutable, sequential writes to keyBuilder will also mutate returned representation. Safe for lookups by key. Should not be used as key for storing items.
func (kb *keyBuilder) UnsafeKey() string {
return *(*string)(unsafe.Pointer(&kb.buf))
}
Cognitive complexity: 0, Cyclomatic complexity: 1
func (*keyBuilder) Write
func (kb *keyBuilder) Write(p []byte) (int, error) {
kb.buf = append(kb.buf, p...)
return len(p), nil
}
Cognitive complexity: 0, Cyclomatic complexity: 1
Private functions
func newCache
newCache (ttl time.Duration, isEnabled bool) *cache
References: gocache.NewCache.
func newRegexpByteRetBoolCache
newRegexpByteRetBoolCache (ttl time.Duration, isEnabled bool) *regexpByteRetBoolCache
func newRegexpCache
newRegexpCache (ttl time.Duration, isEnabled bool, fn func(string) (*regexp.Regexp, error)) *regexpCache
func newRegexpStrFuncRetStrCache
newRegexpStrFuncRetStrCache (ttl time.Duration, isEnabled bool) *regexpStrFuncRetStrCache
func newRegexpStrIntRetSliceSliceStrCache
newRegexpStrIntRetSliceSliceStrCache (ttl time.Duration, isEnabled bool) *regexpStrIntRetSliceSliceStrCache
func newRegexpStrIntRetSliceStrCache
newRegexpStrIntRetSliceStrCache (ttl time.Duration, isEnabled bool) *regexpStrIntRetSliceStrCache
func newRegexpStrRetBoolCache
newRegexpStrRetBoolCache (ttl time.Duration, isEnabled bool) *regexpStrRetBoolCache
func newRegexpStrRetSliceStrCache
newRegexpStrRetSliceStrCache (ttl time.Duration, isEnabled bool) *regexpStrRetSliceStrCache
func newRegexpStrStrRetStrCache
newRegexpStrStrRetStrCache (ttl time.Duration, isEnabled bool) *regexpStrStrRetStrCache
func quote
quote (s string) string
References: strconv.CanBackquote, strconv.Quote.
func add
add (key string, value interface{})
func enabled
enabled () bool
func getBool
getBool (key string) (bool, bool)
func getRegexp
getRegexp (key string) (*regexp.Regexp, bool)
References: regexp.Regexp.
func getStrSlice
getStrSlice (key string) ([]string, bool)
func getStrSliceOfSlices
getStrSliceOfSlices (key string) ([][]string, bool)
func getString
getString (key string) (string, bool)
func reset
reset (ttl time.Duration, isEnabled bool)
func do
do (r *regexp.Regexp, b []byte, noCacheFn func([]byte) bool) bool
func do
do (str string) (*Regexp, error)
func doNoCacheFunc
doNoCacheFunc (str string) (*Regexp, error)
func do
do (r *regexp.Regexp, src string, repl func(string) string, noCacheFn func(string, func(string) string) string) string
func do
do (r *regexp.Regexp, s string, n int, noCacheFn func(s string, n int) [][]string) [][]string
func do
do (r *regexp.Regexp, s string, n int, noCacheFn func(s string, n int) []string) []string
func do
do (r *regexp.Regexp, s string, noCacheFn func(string) bool) bool
func do
do (r *regexp.Regexp, s string, noCacheFn func(s string) []string) []string
func do
do (r *regexp.Regexp, src string, repl string, noCacheFn func(string, string) string) string
Tests
Files: 2. Third party imports: 0. Imports from organisation: 0. Tests: 32. Benchmarks: 13.
Vars
var tStr1 = "aαa⏰𐌈"
var tStr2 = "bβb⏳𐌏"