🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

offline-first-storage

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

offline-first-storage

Offline first storage

0.0.5
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Offline first storage

Offline first logic for yor application

NPM

npm version Build Status Coverage Status Linux Build Windows Build

Dependency Status devDependency Status NSP Status

License GitHub stars GitHub forks GitHub issues Twitter

How to install

npm i -S offline-first-storage

How to use

const OFS = require('offline-first-storage');

const cache = new OFS({
    async getDataFromSource() {},
    async getDataFromCache() {},
    async setDataToCache(data) {},
    async getCacheDate() {},
    async updateCacheDate() {},
    timeoutErrorHandler(error) {},
    ttl: 86400, // 24 hours
});

const data = await cache.getData();

ioredis example

const Redis = require('ioredis');
const redis = new Redis();

const key = 'test';

const cache = new Ofs({
    async getDataFromSource() {
        return test;
    },
    async getDataFromCache() {
        return redis.get(key);
    },
    async setDataToCache(data) {
        await redis.set(key, data);
    },
    async getCacheDate() {
        return redis.get(`date_${key}`);
    },
    async updateCacheDate() {
        await redis.set(`date_${key}`, new Date().valueOf());
    },
    timeoutErrorHandler(error) {
        debug(error);
    },
    ttl: 86400,
});

const data = await cache.getData();

  • ioredis - promise based node.js redis client
  • config - node.js config
  • debug - node.js debugging utility

Keywords

promise

FAQs

Package last updated on 28 Feb 2017

Did you know?

Socket

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.

Install

Related posts