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
aae0de39
Commit
aae0de39
authored
4 years ago
by
Akshay Bharambe
Browse files
Options
Downloads
Patches
Plain Diff
Add: GetAll for fastCache
parent
09b73e64
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!210
Staging mepdeployment05072020
,
!206
Add: Enable users to view data present in session manager
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cachemdl/cachemdl.go
+12
-0
cachemdl/cachemdl.go
cachemdl/cachemdl_test.go
+46
-0
cachemdl/cachemdl_test.go
with
58 additions
and
0 deletions
cachemdl/cachemdl.go
+
12
−
0
View file @
aae0de39
...
...
@@ -103,3 +103,15 @@ func (fastCacheHelper *FastCacheHelper) GetItemsCount() int {
func
(
fh
*
FastCacheHelper
)
Type
()
int
{
return
TypeFastCache
}
// GetAll returns all keys with values present in memory. **This is not intended for production use. May hamper performance**
func
(
fastCacheHelper
*
FastCacheHelper
)
GetAll
()
map
[
string
]
interface
{}
{
items
:=
fastCacheHelper
.
FastCache
.
Items
()
result
:=
make
(
map
[
string
]
interface
{},
len
(
items
))
for
k
,
v
:=
range
items
{
result
[
k
]
=
v
.
Object
}
return
result
}
This diff is collapsed.
Click to expand it.
cachemdl/cachemdl_test.go
+
46
−
0
View file @
aae0de39
//@author Ajit Jagtap
//@version Thu Jul 05 2018 06:11:54 GMT+0530 (IST)
package
cachemdl
import
(
"reflect"
"testing"
)
// import (
// "testing"
// "time"
...
...
@@ -39,3 +46,42 @@ package cachemdl
// cnt = ch.Count()
// assert.Zero(t, cnt, "After Purge Count should be zero")
// }
func
TestFastCacheHelper_GetAll
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
fastCacheHelper
*
FastCacheHelper
want
map
[
string
]
interface
{}
init
func
(
fs
*
FastCacheHelper
)
}{
{
name
:
"Get all items Success"
,
fastCacheHelper
:
&
FastCacheHelper
{},
want
:
map
[
string
]
interface
{}{
"a"
:
1
,
"b"
:
2
,
},
init
:
func
(
fs
*
FastCacheHelper
)
{
fs
.
Setup
(
2
,
0
,
0
)
fs
.
Set
(
"a"
,
1
)
fs
.
Set
(
"b"
,
2
)
},
},
{
name
:
"Get all items Empty"
,
fastCacheHelper
:
&
FastCacheHelper
{},
want
:
map
[
string
]
interface
{}{},
init
:
func
(
fs
*
FastCacheHelper
)
{
fs
.
Setup
(
2
,
0
,
0
)
},
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
tt
.
init
(
tt
.
fastCacheHelper
)
if
got
:=
tt
.
fastCacheHelper
.
GetAll
();
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"FastCacheHelper.GetAll() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
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