Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
aa16bd5a
Commit
aa16bd5a
authored
May 06, 2021
by
Kamron Aroonrua
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cache store
parent
b59c0795
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
storage-cachestore.js
storage-service/lib/storage-cachestore.js
+44
-0
No files found.
storage-service/lib/storage-cachestore.js
0 → 100644
View file @
aa16bd5a
var
redis
=
require
(
'redis'
);
const
PREFIX
=
'bs:cache:storage'
;
module
.
exports
.
create
=
function
(
conf
)
{
return
new
CacheStore
(
conf
);
}
function
CacheStore
(
conf
){
this
.
prefix
=
PREFIX
;
if
(
conf
.
mem
){
this
.
mem
=
conf
.
mem
;
}
else
if
(
conf
.
conn
){
this
.
mem
=
redis
.
createClient
(
conf
.
conn
);
}
}
CacheStore
.
prototype
.
setIndex
=
function
(
storage
,
oid
,
object
,
cb
){
var
key
=
this
.
prefix
+
":"
+
storage
;
this
.
mem
.
hset
(
key
,
oid
,
object
,
cb
);
}
CacheStore
.
prototype
.
getIndex
=
function
(
storage
,
oid
,
cb
)
{
var
key
=
this
.
prefix
+
":"
+
storage
;
this
.
mem
.
hget
(
key
,
oid
,
function
(
err
,
v
){
var
value
=
null
;
if
(
!
err
&&
v
){
value
=
v
;
}
cb
(
err
,
value
);
});
}
CacheStore
.
prototype
.
flush
=
function
(
storage
,
cb
)
{
var
key
=
this
.
prefix
+
":"
+
storage
;
this
.
mem
.
del
(
key
);
if
(
typeof
cb
==
'function'
){
cb
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment