2.1.1 • Published 3 years ago

file-data-cache v2.1.1

Weekly downloads
12
License
MIT
Repository
github
Last release
3 years ago

file-data-cache

Tiny util to cache data from files. Use case: a small amount of files need to be watched

const loadFileData = (filePath, fileContent) => {
    const result = ..... // Do something
    return result // This value will be cached
}

const fileCache = new FileDataCache({
  loadFileData,
  checkInterval: 60000,
  readFile: true
})

// 1. Initial load of data
let processedData = fileCache.loadData(SOME_FILE_PATH)

// 2. Second call to `loadData`
// Cached values will be returned if:
// A/ the ellapsed time between this call and the last time the file was loading is smaller than `checkInterval`
// B/ the last modified date of the file hasn't changed

processedData = fileCache.loadData(SOME_FILE_PATH)
2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago