Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
coreospackage
Commits
b5686136
Commit
b5686136
authored
6 years ago
by
Ajit Jagtap
Browse files
Options
Downloads
Plain Diff
Merge branch 'BigcacheRemoved_SSS' into 'master'
bigcache_removed See merge request
!48
parents
0087687a
c232f1fb
Branches
Branches containing commit
1 merge request
!48
bigcache_removed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cachehelper/cacheHelper.go
+0
-63
cachehelper/cacheHelper.go
with
0 additions
and
63 deletions
cachehelper/cacheHelper.go
deleted
100644 → 0
+
0
−
63
View file @
0087687a
package
cachehelper
import
(
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/coreospackage/logginghelper"
"github.com/allegro/bigcache"
)
const
(
BIGCACHEShards
=
8
BIGCACHEMaxEntrySize
=
1024
BIGCACHEVerbose
=
true
BIGCACHEHardMaxCacheSize
=
0
BIGCACHEMaxEntriesInWindow
=
100000
BIGCACHELifeWindow
=
2
)
var
bigcacheConfig
=
bigcache
.
Config
{
// number of shards (must be a power of 2)
// Shards: 4096,
Shards
:
BIGCACHEShards
,
// time after which entry can be evicted
LifeWindow
:
BIGCACHELifeWindow
*
time
.
Hour
,
// rps * lifeWindow, used only in initial memory allocation
MaxEntriesInWindow
:
BIGCACHEMaxEntriesInWindow
,
// MaxEntriesInWindow: 10,
// max entry size in bytes, used only in initial memory allocation
MaxEntrySize
:
BIGCACHEMaxEntrySize
,
// prints information about additional memory allocation
Verbose
:
BIGCACHEVerbose
,
// cache will not allocate more memory than this limit, value in MB
// if value is reached then the oldest entries can be overridden for the new ones
// 0 value means no size limit
HardMaxCacheSize
:
BIGCACHEHardMaxCacheSize
,
// callback fired when the oldest entry is removed because of its
// expiration time or no space left for the new entry. Default value is nil which
// means no callback and it prevents from unwrapping the oldest entry.
OnRemove
:
nil
,
}
var
cache
,
initErr
=
bigcache
.
NewBigCache
(
bigcacheConfig
)
//GetValue GetValue
func
GetValue
(
key
string
)
([]
byte
,
error
)
{
return
cache
.
Get
(
key
)
}
//SetValue SetValue
func
SetValue
(
key
string
,
value
[]
byte
)
error
{
return
cache
.
Set
(
key
,
value
)
}
//GetLength GetLength
func
GetLength
()
int
{
return
cache
.
Len
()
}
//Callback function executed when cache element is removed.
//Executed only when onRemove of cache config poting to this function
func
onRemove
(
key
string
,
entry
[]
byte
)
{
logginghelper
.
LogInfo
(
key
+
" removed at "
+
time
.
Now
()
.
String
())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets