nativescript-cache is a persistent caching plugin for NativeScript. Use it to store arbitrary data locally for fast access.
Built atop TMCache on iOS, and SharedPreferences on Android.
tns plugin add nativescript-cacheThe cache plugin supports the following methods:
get(key)set(key, value)delete(key)clear
Note that the value of the cache entry must be a string. If you want to store complex data, use JSON.stringify before putting the data in the cache, and JSON.parse on the way out.
varcache=require("nativescript-cache");cache.set("key1","val1");cache.get("key1");// "val1"cache.delete("key1");cache.get("key1");// undefinedcache.set("key2","val2");cache.set("key3","val3");cache.clear();cache.get("key3");// undefined