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
25a3683c
Commit
25a3683c
authored
5 years ago
by
Akshay Bharambe
Browse files
Options
Downloads
Patches
Plain Diff
Add: Check redis connection on setup
1. Add: Check redis connection on setup
parent
73ec22a0
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!134
Mep release271219
,
!130
Add: Redis as a cache to support grid mode
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cachemdl/cache.go
+2
-2
cachemdl/cache.go
cachemdl/cache_redis.go
+8
-0
cachemdl/cache_redis.go
with
10 additions
and
2 deletions
cachemdl/cache.go
+
2
−
2
View file @
25a3683c
...
...
@@ -13,7 +13,7 @@ const (
)
var
(
// ErrInvalidCacheType indicates provided cache type is not supportd
// ErrInvalidCacheType indicates provided cache type is not support
e
d
ErrInvalidCacheType
=
errors
.
New
(
"invalid cache type provided"
)
)
...
...
@@ -44,7 +44,7 @@ func GetCacheInstance(cfg *CacheConfig) Cacher {
return
cfg
.
FastCache
case
TypeRedisCache
:
cfg
.
RedisCache
.
Setup
(
cfg
.
RedisCache
.
Addr
,
cfg
.
RedisCache
.
Password
,
""
,
cfg
.
RedisCache
.
DB
,
cfg
.
RedisCache
.
Expiration
)
cfg
.
RedisCache
.
Setup
(
cfg
.
RedisCache
.
Addr
,
cfg
.
RedisCache
.
Password
,
cfg
.
RedisCache
.
Prefix
,
cfg
.
RedisCache
.
DB
,
cfg
.
RedisCache
.
Expiration
)
return
cfg
.
RedisCache
default
:
...
...
This diff is collapsed.
Click to expand it.
cachemdl/cache_redis.go
+
8
−
0
View file @
25a3683c
...
...
@@ -42,6 +42,7 @@ type RedisCache struct {
opt
*
redis
.
Options
//
keyStr
string
// "<Prefix>:"
addPrefix
bool
//
connected
bool
// will be enabled if redis client connects to server
Addr
string
// redis server address, default "127.0.0.1:6379"
DB
int
// redis DB on provided server, default 0
...
...
@@ -69,6 +70,13 @@ func (rc *RedisCache) Setup(addr, password, prefix string, db int, exp time.Dura
rc
.
opt
=
&
opt
rc
.
cli
=
redis
.
NewClient
(
&
opt
)
if
_
,
err
:=
rc
.
cli
.
Ping
()
.
Result
();
err
!=
nil
{
loggermdl
.
LogError
(
"connection to redis server failed: "
,
err
)
}
else
{
rc
.
connected
=
true
}
if
prefix
!=
""
{
rc
.
keyStr
=
contcat
(
rc
.
Prefix
,
keySplitter
)
rc
.
addPrefix
=
true
...
...
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