New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cacheable

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

12

lib/registry.js

@@ -13,10 +13,16 @@ // Global cache for constructor classes

var fn = isValidFunc(cls.prototype[method], method)
key = key || cached.DEFAULT_PROTO_KEY.replace('{_fn_}', fn[_REALNAME])
key = key || cached.DEFAULT_PROTO_KEY.replace('{_fn_}', method)
hiddenProperty(fn, _REALNAME, fn.name || method)
cls.addCacheKey(key)
cls.prototype['fresh_' + method] = fn
cls.prototype[method] = cached.wrap(fn, key, ttl, cls.prototype)
cls.prototype[method] = cached.wrap(fn, key, ttl)
}
return function _enableCache(method, key, ttl) {
var cls = this, fn
// can pass ttl as the second argument
if ('number' === typeof key) {
ttl = key
key = null
}
if (method[0] === '.') {

@@ -26,3 +32,3 @@ return enableInstCache.call(this, method.slice(1), key, ttl)

fn = isValidFunc(cls[method], method)
key = key || cached.DEFAULT_KEY.replace('{_fn_}', fn[_REALNAME])
key = key || cached.DEFAULT_KEY.replace('{_fn_}', method)
hiddenProperty(fn, _REALNAME, fn.name || method)

@@ -29,0 +35,0 @@ cls['fresh_' + method] = fn

{
"name": "cacheable",
"version": "0.2.5",
"version": "0.2.6",
"description": "A cache wrapper with redis",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -178,2 +178,6 @@ # Cacheable

User.enableCache('.getPostIds', 'posts-{0}-{1}')
// You can omit the key, cacheable will automatically use the method name
User.enableCache('.getPostIds', 3600)
// KEY: '{_model_}:{id}:getTagsIds', expires in: 3600 seconds
```

@@ -183,10 +187,5 @@

For an instance method, the default `key` would be:
{_model_}:{this.id}:{_fn_}
## License
the MIT licence.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc