Skip to content

Commit

Permalink
release: v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharf5 committed Jul 16, 2022
1 parent 8a8c0fc commit 069f486
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v3.1.0

- Updated Readme.md

## v3.0.0

### Breaking Changes
Expand Down
68 changes: 32 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ npm install --save runtime-memcache
yarn add runtime-memcache
```

## Usage

### Node Environment (ES6+ import/export)

```javascript
Expand All @@ -55,9 +53,9 @@ const createStore = require('runtime-memcache');
### Browser (use as a script tag)

```html
<script src="https://unpkg.com/runtime-memcache@2.0.0/dist/umd/index.js"></script>
<script src="https://unpkg.com/runtime-memcache@3.0.0/dist/umd/index.js"></script>
<!-- OR JUST -->
<script src="https://unpkg.com/runtime-memcache@2.0.0"></script>
<script src="https://unpkg.com/runtime-memcache@3.0.0"></script>
<script>
// RMStore is globaly set
const store = new RMStore();
Expand Down Expand Up @@ -108,38 +106,9 @@ Following caching policies are supported.
| tlru | `set`, `get`, `remove` | O(1), O(1), O(1) |
| mru | `set`, `get`, `remove` | O(1), O(1), O(1) |

## Example

```typescript
import createStore from 'runtime-memcache';

const config = {
policy: 'timeout',
timeToClear: 7200000, // 2 hours
};

interface Response {
name: string;
}

type Keys = 'key1' | 'key2';

const store = createStore<Keys, Response>(config);

store.set('key1', { name: 'name' }); // store the object and associate it with the provided key

store.get('key1'); // retrieves the object associated with this key

store.has('key1'); // returns true

store.size(); // returns 1

store.keys(); // returns ['key1']

store.remove('key1'); // deletes the object associated with this key
```
## Usage

</br>
### Typescript

```typescript
import createStore, { Config } from 'runtime-memcache';
Expand All @@ -160,14 +129,41 @@ async function loginUser(userId: string) {
return userCache.get(userId);
}

const user = await UserService.getUser(userId);
const user: User = await UserService.getUser(userId);

userCache.set(userId, user);

return user;
}
```

### Javascript

```javascript
import createStore from 'runtime-memcache';

const config = {
policy: 'timeout',
timeToClear: 7200000, // 2 hours
};

type Keys = 'key1' | 'key2';

const store = createStore(config);

store.set('key1', { name: 'name' }); // store the object and associate it with the provided key

store.get('key1'); // retrieves the object associated with this key

store.has('key1'); // returns true

store.size(); // returns 1

store.keys(); // returns ['key1']

store.remove('key1'); // deletes the object associated with this key
```

## NPM Script Commands

- `npm run test` -- Runs tests, lint and build.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "runtime-memcache",
"version": "3.0.0",
"version": "3.1.0",
"description": "A no dependency javascript runtime key-value cache store for small chunks of arbitrary data (strings, objects, numbers)",
"homepage": "https://github.com/tusharf5/runtime-memcache",
"main": "./dist/umd/index.js",
Expand Down

0 comments on commit 069f486

Please sign in to comment.