Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feather-cache

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feather-cache - npm Package Compare versions

Comparing version 1.2.1 to 1.3.1

9

dist/src/index.d.ts

@@ -28,3 +28,10 @@ import { IFeatherCacheDriver } from './feather-cache-driver.interface';

*/
fetch(key: string): Promise<{
fetch(key: string, options?: {
/**
* Deletes the record after expiry get.
* default is `true`.
* If you need to hold the delete, unset this option.
*/
delete: boolean;
}): Promise<{
validTill: Date;

@@ -31,0 +38,0 @@ key: string;

6

dist/src/index.js

@@ -62,3 +62,3 @@ "use strict";

*/
fetch(key) {
fetch(key, options = { delete: true }) {
return __awaiter(this, void 0, void 0, function* () {

@@ -71,3 +71,5 @@ const data = yield this.options.getFn.call(this, key);

// expired
yield this.options.delFn.call(this, key);
if (options.delete) {
yield this.options.delFn.call(this, key);
}
data.__$EXPIRED = true;

@@ -74,0 +76,0 @@ }

{
"name": "feather-cache",
"version": "1.2.1",
"version": "1.3.1",
"description": "A Simple Lightweight Pluggable Key-Value Cache For Multiple Storage Options.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/vajahath/feather-cache#readme",

@@ -63,8 +63,8 @@ # feather-cache

| function | description |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FeatherCache.set(key, val, opt)` | returns `Promise`.<br>**`key`**: string<br>**`val`**: any data to be stored <br>**`opt`**: (optional) `{ maxAgeInMs: 1000 }`, sets expiry time. |
| `FeatherCache.get(key)` | returns `Promise` which resolves to the stored data. else, `null`. <br> If data has expired returns `null` and then deletes the entry behind the scenes. |
| `FeatherCache.fetch(key)` | returns `Promise` which resolves to stored data. The difference between `get` and `fetch` is that, `fetch` returns the stored data one more time after its expiry and then deletes it.<br>**More info:**<br>`get`: `finds data -> if expired deletes it -> returns null`.<br>`fetch`: `finds data -> if expired returns it -> and then deletes it`. |
| `FeatherCache.del(key)` | returns `Promise` deletes the entry |
| function | description |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `FeatherCache.set(key, val, opt)` | returns `Promise`.<br>**`key`**: string<br>**`val`**: any data to be stored <br>**`opt`**: (optional) `{ maxAgeInMs: 1000 }`, sets expiry time. |
| `FeatherCache.get(key)` | returns `Promise` which resolves to the stored data. else, `null`. <br> If data has expired returns `null` and then deletes the entry behind the scenes. |
| `FeatherCache.fetch(key)` | returns `Promise` which resolves to stored data. The difference between `get` and `fetch` is that, `fetch` returns the stored data one more time after its expiry and then deletes it.<br>**More info:**<br>`get`: `finds data -> if expired deletes it -> returns null`.<br>`fetch`: `finds data -> if expired returns it -> and then deletes it`.<br> However, you can control this behavior by passing the `delete` option (default `delete: true`). Eg: `fStore.fetch('hiya', { delete: false })`. This sets the expiry flag but don't delete it. Sometimes you may find this helpful. |
| `FeatherCache.del(key)` | returns `Promise` deletes the entry |

@@ -71,0 +71,0 @@ ## Configuration / writing drivers

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