Giter Club home page Giter Club logo

coa-file-storage's Introduction

coa-file-storage

GitHub license npm version npm downloads PRs Welcome

轻量的文件储存/缓存工具 for Node.js

可为轻量应用、演示应用或简单的静态应用等提供数据存储的能力,使用文件作为存储介质,零依赖,性能高,方便快捷。

特性

  • 简单轻量 不超过 100 行代码,不依赖于其他第三方库
  • 自动缓存 内置内存缓存,不需要频繁读写 IO,性能友好(请在单机应用下使用)
  • TypeScript 全部使用 TypeScript 书写,类型约束、IDE 友好

快速开始

安装

yarn add coa-file-storage

快速开始

import { CoaFileStorage } from 'coa-file-storage'

// 创建一个新的示例
const fileStorage = new CoaFileStorage('/path/file-storage/data')

// 获取一个未设置的值,此时返回undefined
fileStorage.get('key1') // undefined

// 设置储存信息
fileStorage.set('key1', { info: 'this is value' }, 60 * 1000)

// 获取设置的值,能得到正确的存储数据
fileStorage.get('key1') // { info: 'this is value' }

// 超过60秒后,数据过期,返回undefined
fileStorage.get('key1') // undefined

coa-file-storage's People

Contributors

adaex avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.