You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cache is the central cache implementation for several modules.
8
+
Cache is the central cache implementation module for several modules.
9
9
It contains three caching engines. The decision of which caching engine to use is governed while creating the cache object.
10
10
The caching engines implemented are:
11
11
12
12
*[Memcached](https://memcached.org/)
13
13
*[Redis](https://redis.io/docs/)
14
14
* In-memory (use with single threaded process in development mode only)
15
+
15
16
## Why Cache?
16
-
Implementation method varies according to caching systems.
17
-
So implementing different caching systems is always a overhead for developer.
18
-
Our package solve this problem by providing common wrapper methods for memcached, redis and in-memory caching system.
17
+
Core packages of different caching systems do not have a common interface, i.e. they have the same functionality implemented with different method signatures.
18
+
Thus changing from one cache system to another becomes difficult as all the usages need to be revisited.
19
+
This NPM package solves the problem by providing common wrapper methods for memcached, redis and in-memory caching systems.
19
20
20
21
## Prerequisites
21
22
Required caching engine for the use case must be installed and up.
22
-
Refer [memcached](https://gist.github.com/tomysmile/ba6c0ba4488ea51e6423d492985a7953) and [redis](https://flaviocopes.com/redis-installation/) installation guide.
23
+
Refer [memcached](https://memcached.org/) and [redis](https://redis.io/docs/getting-started/installation/) installation guide.
23
24
24
-
## Install NPM
25
-
```bash
25
+
## Installion
26
+
```shell script
26
27
npm install @plgworks/cache --save
27
28
```
28
29
29
30
## Initialize
30
31
31
-
####Cache Initialization Params
32
+
### Cache Initialization Params
32
33
**`configStrategy`** is a mandatory parameter which specifies the configuration strategy to be used for a particular cache engine.
33
34
An example of the configStrategy is:
34
35
```js
@@ -96,106 +97,68 @@ configStrategy = {
96
97
}
97
98
}
98
99
```
99
-
Note: To print detailed logs, add `CACHE_DEBUG_ENABLED = '1'` in your env variables.
100
-
## Examples:
101
100
102
-
####Create Cache Object:
101
+
### Create Cache Object:
103
102
104
103
```js
105
104
Cache =require('@plgworks/cache');
106
105
cache =Cache.getInstance(configStrategy);
107
106
108
107
cacheImplementer =cache.cacheInstance;
109
108
```
109
+
Note: To print detailed logs, add `CACHE_DEBUG_ENABLED = '1'` in your env variables.
110
+
111
+
## Examples:
110
112
111
-
####Store and retrieve data in cache using `set` and `get`:
113
+
### Store and retrieve data in cache using `set` and `get`:
####Retrieve multiple cache data using `multiGet`:
136
+
### Retrieve multiple cache data using `multiGet`:
150
137
151
-
###### * <b>NOTE: Redis returns null from `multiGet` for objects, even if a value is set in the cache; the other caching engines match this behaviour.</b>
138
+
<b>NOTE: Redis returns null from `multiGet` for objects, even if a value is set in the cache. The other caching implementers match this behaviour.</b>
0 commit comments