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

file-cacher

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-cacher

File system and mem-cache for files

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-0.62%
Maintainers
1
Weekly downloads
 
Created
Source

File Cacher

Description

This package will handle file caching for services in need for fast file access. In essence, it will cache common files in memory, while less common files will be accessed from file system.

Additionally, it will cache similar requests promises. meaning, if two request for downloading the same file are being sent paralleled, it will only generate one request.

Usage


const fileCacher = new FileCacher({
      tmpDir: './tmp',
      debug : true,
      maxFileSystemCacheSize: 1000, // in MB
      maxInMemoryCacheSize: 300, // in MB
});


const filesGroupIdentifier = 'assets'

function getBundleFile() {
    const fileName = 'dist/bundle.aa8w37vhr.js';
    const fileUrl = `https://app.logz.io/${fileName}`;
    const fileGetter = () => fetch(fileUrl, { compress: true });
    
    return fileCacher.get(filesGroupIdentifier, fileName, fileGetter); 
}

getFile()
    .then(file => {
        console.log(file);
    })

Keywords

FAQs

Package last updated on 24 Nov 2020

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

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