https://github.com/fjc0k/ok-cache
PHP Laravel cache like for Javascript
https://github.com/fjc0k/ok-cache
cache
Last synced: 6 months ago
JSON representation
PHP Laravel cache like for Javascript
- Host: GitHub
- URL: https://github.com/fjc0k/ok-cache
- Owner: fjc0k
- Created: 2017-02-19T21:21:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-28T02:20:52.000Z (over 8 years ago)
- Last Synced: 2025-03-31T09:16:55.188Z (6 months ago)
- Topics: cache
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ok-cache
## Install
```shell
npm i ok-cache --save
```## Usage
```javascript
import OkCache from 'ok-cache';const cache = new OkCache({
prefix: 'app_', // default: ''
driver: 'wxapp', // default: 'localStorage'
promise: Promise // default: window.Promise, 需自行引入Promise-polyfill, 在微信小程序中务必传入此参数
});cache.flush().rememberMany({
userInfo (resolve) {
setTimeout(() => resolve({
name: 'Lily',
gender: 'female'
}), 1000);
},
commonSettings (resolve) {
setTimeout(() => resolve({
siteName: 'DREAM',
showModal: false
}), 2000);
}
}).then(({ userInfo, commonSettings }) => {
console.log(`${userInfo.name}, welcome to ${commonSettings.siteName}`);
});
```