https://github.com/recursivefunk/mulla
💸 [WIP] Redis backed promise cache (cash (mulla))
https://github.com/recursivefunk/mulla
Last synced: 3 months ago
JSON representation
💸 [WIP] Redis backed promise cache (cash (mulla))
- Host: GitHub
- URL: https://github.com/recursivefunk/mulla
- Owner: recursivefunk
- Created: 2016-07-19T00:38:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-09T21:27:19.000Z (over 9 years ago)
- Last Synced: 2025-08-09T11:27:33.271Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mulla [WIP]
Mulla uses redis to cache the results for expensive operations.
```javascript
const env = require('good-env')
const P = require('bluebird')
const Mulla = require('mulla')
const aFunc = () => {
return new P((resolve) => {
const result = {
foo: 'bar'
}
setTimeout(() => resolve(result), 3000)
})
}
const url = env.get('REDIS_URL', 'redis://localhost:6379')
const aFuncCache = Mulla({ url })
aFuncCache.withKey('results:aFunc').wrap(aFunc)
aFuncCache.run()
.then((result) => {
// Cache miss! At least 3 seconds later
})
// ... some time later
aFuncCache.run()
.then((result) => {
// Cache hit! Returns as fast as redis/network can deliver!
})
```
Mulla is designed to work best for side-effect-free functions calls - the same input(s) should yield the same output every
time the function is run. Mulla also assumes promise return values