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
corepkgv2
Commits
bfe205bb
There was an error fetching the commit references. Please try again later.
Commit
bfe205bb
authored
5 years ago
by
Deepak Prakash Karn
Browse files
Options
Downloads
Plain Diff
Merge branch 'devbranch' into dpk_randomGenerationFix
parents
ebc526f7
26f08ebb
1 merge request
!83
Dpk random int generation fix
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cachemdl/cachemdl.go
+0
-61
cachemdl/cachemdl.go
with
0 additions
and
61 deletions
cachemdl/cachemdl.go
+
0
−
61
View file @
bfe205bb
...
...
@@ -7,70 +7,9 @@ package cachemdl
import
(
"time"
"github.com/bluele/gcache"
"github.com/patrickmn/go-cache"
)
// GCCacheHelper use this to create new cache object
// Remember it holds memory
type
GCCacheHelper
struct
{
GC
gcache
.
Cache
Expiration
time
.
Duration
MaxEntries
int
}
//Setup create new object of GC
func
(
gchelper
*
GCCacheHelper
)
Setup
(
MaxEntries
int
,
Expiration
time
.
Duration
)
{
gchelper
.
MaxEntries
=
MaxEntries
gchelper
.
Expiration
=
Expiration
gchelper
.
GC
=
gcache
.
New
(
MaxEntries
)
.
LFU
()
.
Build
()
}
//TODO: Check if you have SetUp value
// //Setup create new object of GC
// func (gchelper *GCCacheHelper) SetupWithCallbackFunction(MaxEntries int, Expiration time.Duration, f func(key interface{}, value interface{}) error) {
// gchelper.MaxEntries = MaxEntries
// gchelper.Expiration = Expiration
// gchelper.GC = gcache.New(MaxEntries).
// LFU().
// EvictedFunc(func(key, value interface{}) {
// f(key, value)
// }).
// Build()
// }
//New Add new Key and value
func
(
gchelper
*
GCCacheHelper
)
Set
(
key
string
,
object
interface
{})
error
{
return
gchelper
.
GC
.
SetWithExpire
(
key
,
object
,
gchelper
.
Expiration
)
}
//Get object based on key
func
(
gchelper
*
GCCacheHelper
)
Get
(
key
string
)
(
interface
{},
error
)
{
return
gchelper
.
GC
.
Get
(
key
)
}
// GetAll objects from gc
func
(
gchelper
*
GCCacheHelper
)
GetAll
()
map
[
interface
{}]
interface
{}
{
return
gchelper
.
GC
.
GetALL
()
}
// Remove object from GC
func
(
gchelper
*
GCCacheHelper
)
Remove
(
key
string
)
bool
{
return
gchelper
.
GC
.
Remove
(
key
)
}
//Purge all objects
func
(
gchelper
*
GCCacheHelper
)
Purge
()
{
gchelper
.
GC
.
Purge
()
}
// Count all objects
func
(
gchelper
*
GCCacheHelper
)
Count
()
int
{
return
gchelper
.
GC
.
Len
()
}
type
FastCacheHelper
struct
{
FastCache
*
cache
.
Cache
Expiration
time
.
Duration
...
...
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