Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thinkjs/think-memcache
ThinkJS memcache
https://github.com/thinkjs/think-memcache
memcache
Last synced: 20 days ago
JSON representation
ThinkJS memcache
- Host: GitHub
- URL: https://github.com/thinkjs/think-memcache
- Owner: thinkjs
- License: mit
- Created: 2017-03-27T01:22:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T00:18:16.000Z (over 3 years ago)
- Last Synced: 2024-12-13T00:33:39.972Z (about 1 month ago)
- Topics: memcache
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- think-awesome - think-memcache
README
# think-memcache
[![Build Status](https://travis-ci.org/thinkjs/think-memcache.svg?branch=master)](https://travis-ci.org/thinkjs/think-memcache)
[![Coverage Status](https://coveralls.io/repos/github/thinkjs/think-memcache/badge.svg?branch=master)](https://coveralls.io/github/thinkjs/think-memcache?branch=master)
[![npm](https://img.shields.io/npm/v/think-memcache.svg?style=flat-square)](https://www.npmjs.com/package/think-memcache)## Install
```
npm install think-memcache
```## How to Usage
### default options
You can find all the config options at http://memcache-plus.com/
```js
const defaultOptions = {
hosts: ['127.0.0.1:11211'],
maxValueSize: 1048576,
netTimeout: 5000,
reconnect: true
}
```### usage
```js
import Memcache from '../index';let memInst = new Memcache(config);
// set key, expire should be milliseconds
let s1 = await memInst.set('name2', 'lushijie'); // expire = 0
let s2 = await memInst.set('name3', 'lushijie', 3000); // milliseconds// get key's value
let g1 = await memInst.get('name2');// delete key
await memInst.delete(key);// increase 1, key'value should be integer, if key not exist will do nothing
await memInst.increase(key);// decrease 1, key'value should be integer, if key not exist will do nothing
await memInst.decrease(key);```