1.0.0 • Published 2 years ago

local-caches v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Usage

Install

npm install local-caches

Use

import { getCache, setCache } from 'local-caches'

setCache('baz', 'foo')
const val = getCache('baz') // 'foo'

you can add ".cache/*" to your ".gitignore" file when you don't commit cache file.

Configs

interface CachesConfig {
  // the dirname of saving caches
  // default '.cache'
  pathName?: `.${string}`
  // the filename of saving caches
  // default 'index'
  fileName?: string
}

API

getCaches

Used for getting all caches in a specified configuration.

declare const getCaches: (config?: CachesConfig | undefined) => Record<string, string> | null

getCache

Used for getting a specified cache in a specified configuration.

declare const getCache: (key: string, config?: CachesConfig | undefined) => string | undefined

setCache

Used for setting cache in a specified configuration.

declare const setCache: (key: string, value: string, config?: CachesConfig | undefined) => void

removeCache

Used for removing a specified cache in a specified configuration.

declare const setCache: (key: string, value: string, config?: CachesConfig | undefined) => void

clearCaches

Use for clear all caches in a specified configuration.

declare const clearCaches: (config?: CachesConfig | undefined) => void

License

MIT License © 2022 Dewey Ou