[waf]支持包含二进制、不支持二进制等操作符;支持对参数值编解码

This commit is contained in:
刘祥超
2020-11-21 20:44:19 +08:00
parent b14dae74f1
commit defbb1ccb9
12 changed files with 425 additions and 2 deletions

57
internal/cache/piece.go vendored Normal file
View File

@@ -0,0 +1,57 @@
package cache
import (
"github.com/TeaOSLab/EdgeNode/internal/utils"
"sync"
"time"
)
type Piece struct {
m map[uint64]*Item
locker sync.RWMutex
}
func NewPiece() *Piece {
return &Piece{m: map[uint64]*Item{}}
}
func (this *Piece) Add(key uint64, item *Item) () {
this.locker.Lock()
this.m[key] = item
this.locker.Unlock()
}
func (this *Piece) Delete(key uint64) {
this.locker.Lock()
delete(this.m, key)
this.locker.Unlock()
}
func (this *Piece) Read(key uint64) (item *Item) {
this.locker.RLock()
item = this.m[key]
if item != nil && item.expiredAt < utils.UnixTime() {
item = nil
}
this.locker.RUnlock()
return
}
func (this *Piece) Count() (count int) {
this.locker.RLock()
count = len(this.m)
this.locker.RUnlock()
return
}
func (this *Piece) GC() {
this.locker.Lock()
timestamp := time.Now().Unix()
for k, item := range this.m {
if item.expiredAt <= timestamp {
delete(this.m, k)
}
}
this.locker.Unlock()
}