Add method GetCacheBytes(c *cache) int
This commit is contained in:
parent
a3647f8e31
commit
a8011e21b9
12
cache.go
12
cache.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -1159,3 +1160,14 @@ func New(defaultExpiration, cleanupInterval time.Duration) *Cache {
|
||||||
func NewFrom(defaultExpiration, cleanupInterval time.Duration, items map[string]Item) *Cache {
|
func NewFrom(defaultExpiration, cleanupInterval time.Duration, items map[string]Item) *Cache {
|
||||||
return newCacheWithJanitor(defaultExpiration, cleanupInterval, items)
|
return newCacheWithJanitor(defaultExpiration, cleanupInterval, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return a Bytes cache has as int.
|
||||||
|
// To Evaluate memory and cache usage.
|
||||||
|
func GetCacheBytes(c *cache) int {
|
||||||
|
|
||||||
|
cacheitems := c.Items()
|
||||||
|
ptrcachebyte := uintptr(len(cacheitems)) * reflect.TypeOf(cacheitems).Elem().Size()
|
||||||
|
cachebyte := int(ptrcachebyte)
|
||||||
|
|
||||||
|
return cachebyte
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue