react-native-web-cache
v0.5.0
Published
An LRU cache built with React Native in mind
Downloads
9
Maintainers
Readme
react-native-web-cache
Installation
NPM
npm install --save react-native-web-cache
Yarn
yarn add react-native-web-cache
Bower
bower install --save react-native-web-cache
Usage
JavaScript
var webCache = require("react-native-web-cache");
var cacheOptions = { capacity: 10 };
var cache = new webCache.Cache(cacheOptions);
async function() {
await cache.setAsync("key", 42);
var value = await cache.getAsync("key"); // value = 42
}
TypeScript
import { Cache, ICache, ICacheOptions } from "react-native-web-cache";
const cacheOptions: ICacheOptions = { capacity: 10 };
const cache: ICache = new Cache(cacheOptions);
const asyncFunction = async (): Promise<void> => {
cache.setAsync<number>("key", 42).then((): void => {
cache.getAsync<number>("key").then((value: number): number => value); // value = 42
});
};