Creates a cache interface to your file system in an easy way.
youcache
does not return the contents of the cached files, it only returns their path and hash.
import YouCache from 'youcache'
const YouCache = require('youcache')
Create a new instance.
const cache = new YouCache('my-cache') // The name is required.
Returns the path of the cache on the device.
console.log(cache.path)
Adds a file to the cache, putting the contents of the file, returns an object with the path to the file in the cache and the hash of the file.
await cache.add('file_path', 'content') // {hash,path}
Creates a new file path in the cache without creating any file, returns an object with the path to the file in the cache and the hash of the file.
await cache.create('file_path') // {hash,path}
Returns an object with the path to the file in the cache and the hash of the file, if it does not exist it will return null
.
await cache.get('file_path') // {hash,path}
Removes the file from the cache.
await cache.remove('file_path')
Clears the entire contents of the cache.
await cache.clear()