Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
capped-cache
Advanced tools
An abstraction of the NodeCache memory cache that supports a max size option.
Supports 0.12.x and above.
npm i --save capped-cache
The API essentially matches that of NodeCache, but with a couple of additional behaviours.
function CappedCache([options])
A constructor function that creates a new instance of CappedCache, with an associated NodeCache instance under the hood. options
is an optional object that permits the configuration of the cache:
maxSize
- the maximum number of objects that CappedCache can store at any given timedefaultTTL
- the default TTL, in seconds, for objects stored in the cacheSo that performance isn't compromised, the instance of NodeCache created under the hood will have its useClones
option set to false
.
CappedCache.prototype.get(cacheKey)
Gets the object associated with the specified cache key. cacheKey
must be a String
. If the key is not found, then this method will return undefined
.
CappedCache.prototype.set(cacheKey, data, [ttl])
Stores an object in the cache with the associated key. An optional TTL can be passed if one wishes to override the default.
This method returns a Boolean
that reflects whether the item was successfully stored:
maxSize
, then this will return false
, and the item will not be storedtrue
.CappedCache.prototype.flushAll()
Flushes all data from the cache.
npm i
Unit tests are written with Mocha, Chai, and Sinon. Run with npm test
.
Definitely more than happy to accept pull requests. Just be sure to use tabs instead of spaces, as this is the existing formatting convention.
FAQs
An abstraction of NodeCache that supports a max size option
We found that capped-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.