added cache test
This commit is contained in:
parent
83cd654030
commit
a1a335a53c
2 changed files with 22 additions and 2 deletions
5
cache.go
5
cache.go
|
|
@ -27,7 +27,7 @@ func NewQueryCache(max int) *QueryCache {
|
|||
// NewQuery looks for the given query in the cache and returns it.
|
||||
// If the query is not found it will be generated and inserted in the cache..
|
||||
func (qc *QueryCache) NewQuery(s string) (q *Query, err error) {
|
||||
q = qc.lookup(s)
|
||||
q = qc.Lookup(s)
|
||||
if q != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -44,7 +44,8 @@ func (qc *QueryCache) NewQuery(s string) (q *Query, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (qc *QueryCache) lookup(s string) *Query {
|
||||
// Lookup looks for a given query string and returns the query object or nil.
|
||||
func (qc *QueryCache) Lookup(s string) *Query {
|
||||
qc.RLock()
|
||||
defer qc.RUnlock()
|
||||
if q, ok := qc.m[s]; ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue