GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - node-modules/diskstore: a local cache implement

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
lib
lib
 
 
test
test
 
 
.eslintignore
.eslintignore
 
 
.eslintrc
.eslintrc
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
History.md
History.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 

Repository files navigation

diskstore

a basic local cache implementation

NPM version Node.js CI Test coverage npm download

Introduction

A basic file cache implementation. It just providers low-level APIs (get, set, delete) to allow you read & atomic write from file cache. You can also create your implementation by inheriting or wrapping it.

Install

npm install diskstore --save

APIs

  • new DiskStore(options)
    • {String} cacheDir - root cache dir
    • {Boolean} [fallback=true] - when the internal rename fails with EXDEV (the .tmp dir and the target file are on different filesystems), retry by writing a temp file in the target file's own directory and rename it there, which stays atomic. Set to false to let the EXDEV error throw.
    • {String} [fallbackTmpfileName] - the temp file name used by the fallback, placed in the target file's directory. Defaults to a random name. A fixed name is only safe when concurrent writes to the same directory cannot happen; otherwise keep the default so each write gets a unique temp file.
  • async get(relativePath) read data from relativePath if the file exists.
    • {String} relativePath - file path relative to root cache dir
  • async set(relativePath, data) write data to relativePath
    • {String} relativePath - file path relative to root cache dir
    • {Buffer|String} data - the data
  • async delete(relativePath) delete the file
    • {String} relativePath - file path relative to root cache dir

Usage

const diskStore = new DiskStore({
  cacheDir: '/path/cache',
});

await diskStore.set('a/b/c', 'c');
let data = await diskStore.get('a/b/c');
assert.deepEqual(data, Buffer.from('c'));

await diskStore.delete('a/b/c');
data = await diskStore.get('a/b/c');
assert(data === null);

License

MIT

Contributors


leoner


gxcsoccer


fengmk2

This project follows the git-contributor spec, auto updated at Thu Jun 02 2022 15:25:27 GMT+0800.

About

a local cache implement

Resources

Readme
MIT license
Activity
Custom properties

Stars

8 stars

Watchers

11 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.