mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
enhance: proxy settings
This commit is contained in:
parent
957d4754f7
commit
deda31a6e1
15 changed files with 351 additions and 261 deletions
10
internal/cache/cache.go
vendored
10
internal/cache/cache.go
vendored
|
@ -6,11 +6,11 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var cache *ristretto.Cache
|
||||
var cache *ristretto.Cache[string, any]
|
||||
|
||||
func Init() {
|
||||
var err error
|
||||
cache, err = ristretto.NewCache(&ristretto.Config{
|
||||
cache, err = ristretto.NewCache[string, any](&ristretto.Config[string, any]{
|
||||
NumCounters: 1e7, // number of keys to track frequency of (10M).
|
||||
MaxCost: 1 << 30, // maximum cost of cache (1GB).
|
||||
BufferItems: 64, // number of keys per Get buffer.
|
||||
|
@ -21,15 +21,15 @@ func Init() {
|
|||
}
|
||||
}
|
||||
|
||||
func Set(key interface{}, value interface{}, ttl time.Duration) {
|
||||
func Set(key string, value interface{}, ttl time.Duration) {
|
||||
cache.SetWithTTL(key, value, 0, ttl)
|
||||
cache.Wait()
|
||||
}
|
||||
|
||||
func Get(key interface{}) (value interface{}, ok bool) {
|
||||
func Get(key string) (value interface{}, ok bool) {
|
||||
return cache.Get(key)
|
||||
}
|
||||
|
||||
func Del(key interface{}) {
|
||||
func Del(key string) {
|
||||
cache.Del(key)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue