Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexdonh/adonis-cache
Another cache provider for AdonisJs. Supports Object, File, Db and Redis cache. With cache dependencies!
https://github.com/alexdonh/adonis-cache
adonis-framework adonisjs cache data dependency redis storing
Last synced: 23 days ago
JSON representation
Another cache provider for AdonisJs. Supports Object, File, Db and Redis cache. With cache dependencies!
- Host: GitHub
- URL: https://github.com/alexdonh/adonis-cache
- Owner: alexdonh
- License: mit
- Created: 2019-11-04T08:19:05.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-13T06:22:41.000Z (about 5 years ago)
- Last Synced: 2024-12-26T02:07:20.795Z (27 days ago)
- Topics: adonis-framework, adonisjs, cache, data, dependency, redis, storing
- Language: JavaScript
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Adonis Cache
Another cache provider for [AdonisJs](https://github.com/adonisjs/adonis-framework). Supports Object, File, Db and Redis data store. It also supports cache dependencies.
## Installation
```bash
$ adonis install git+https://github.com/alexdonh/adonis-cache.git --as=adonis-cache
```Install optional dependencies to use. For example, install
```bash
$ npm i fs-extra microtime moment proper-lockfile
```to use file store caching.
## Setup
1. Register cache providers in `start/app.js` file.
```js
const providers = [
...
'@adonisjs/lucid/providers/LucidProvider',
'adonis-cache/providers/CacheProvider'
]const aceProviders = [
...
'@adonisjs/lucid/providers/MigrationsProvider',
'adonis-cache/providers/CommandsProvider'
]
```4. Run the migrations if using db store cache. See [https://adonisjs.com/docs/4.1/migrations](https://adonisjs.com/docs/4.1/migrations)
```bash
$ adonis migration:run
```## Usage
```js
const Cache = use('Adonis/Addons/Cache') // or alias: use('Cache')// set cache
await Cache.set('key', 'This is a value', 60 * 60 * 24) // 24 hours// get cache
await Cache.get('key')// add cache, error if key exists
await Cache.add('key', something)// check if cache exists
await Cache.exists('key')// delete cache
await Cache.delete('key')// flush all caches
await Cache.flush()// use another cache store 'key', 'db', 'object', 'redis', or your own custom store
await Cache.store('file').get('key')```
## Register a custom cache store
Updating...
## Credits
- [Alex Do](https://github.com/alexdonh)
## Support
Having trouble? [Open an issue](https://github.com/alexdonh/adonis-cache/issues/new)!
## License
The MIT License (MIT). See [License File](LICENSE) for more information.