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
e551e7b1
Commit
e551e7b1
authored
5 years ago
by
Akshay Bharambe
Browse files
Options
Downloads
Patches
Plain Diff
Add: Expose current cache instance.
parent
4e74a6af
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!173
Mep release19032020
,
!170
Add: Functionality to call session manager from bls.
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cachemdl/cache.go
+8
-0
cachemdl/cache.go
cachemdl/cache_redis.go
+9
-1
cachemdl/cache_redis.go
cachemdl/cachemdl.go
+10
-1
cachemdl/cachemdl.go
with
27 additions
and
2 deletions
cachemdl/cache.go
+
8
−
0
View file @
e551e7b1
...
...
@@ -17,6 +17,14 @@ var (
ErrInvalidCacheType
=
errors
.
New
(
"invalid cache type provided"
)
)
var
(
// Set @Setup(), CacheInUse provides current cache in use. We can take decision to perform cache specific operations with this.
CacheInUse
int
// Set @setup(), if true, cache is already initialized
initialized
bool
)
// Cacher provides access to underlying cache, make sure all caches implement these methods.
type
Cacher
interface
{
// SET
...
...
This diff is collapsed.
Click to expand it.
cachemdl/cache_redis.go
+
9
−
1
View file @
e551e7b1
...
...
@@ -52,8 +52,13 @@ type RedisCache struct {
Prefix
string
// this will be used for storing keys for provided project
}
// Setup
-
// Setup
initializes redis cache for application. Must be called only once.
func
(
rc
*
RedisCache
)
Setup
(
addr
,
password
,
prefix
string
,
db
int
,
exp
time
.
Duration
)
{
if
initialized
{
loggermdl
.
LogError
(
"cache instance is already initialized"
)
return
}
if
rc
==
nil
{
rc
=
new
(
RedisCache
)
}
...
...
@@ -84,6 +89,9 @@ func (rc *RedisCache) Setup(addr, password, prefix string, db int, exp time.Dura
rc
.
keyStr
=
contcat
(
rc
.
Prefix
,
keySplitter
)
rc
.
addPrefix
=
true
}
CacheInUse
=
TypeRedisCache
initialized
=
true
}
// Set marshalls provided value and stores against provided key. Errors will be logged to initialized logger.
...
...
This diff is collapsed.
Click to expand it.
cachemdl/cachemdl.go
+
10
−
1
View file @
e551e7b1
...
...
@@ -7,6 +7,7 @@ package cachemdl
import
(
"time"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"github.com/patrickmn/go-cache"
)
...
...
@@ -19,11 +20,19 @@ type FastCacheHelper struct {
MaxEntries
int
}
//Setup
create new object of GC
//
Setup
initializes fastcache cache for application. Must be called only once.
func
(
fastCacheHelper
*
FastCacheHelper
)
Setup
(
maxEntries
int
,
expiration
time
.
Duration
,
cleanupTime
time
.
Duration
)
{
if
initialized
{
loggermdl
.
LogError
(
"cache instance is already initialized"
)
return
}
fastCacheHelper
.
MaxEntries
=
maxEntries
fastCacheHelper
.
Expiration
=
expiration
fastCacheHelper
.
FastCache
=
cache
.
New
(
fastCacheHelper
.
Expiration
,
fastCacheHelper
.
CleanupTime
)
CacheInUse
=
TypeFastCache
initialized
=
true
}
// Get -
...
...
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