1

Is there an actively maintained nativescript plugin for data caching?

like nativescript-cache but sadly this plugin is now inactive.

Jannomeister
  • 621
  • 4
  • 23
  • What is the goal - what do you need to cache? The latest NativeScript modules are coming with a build-in mechanism for caching images https://docs.nativescript.org/angular/best-practices/images-optimisations#using-usecache-property – Nick Iliev May 22 '18 at 13:49
  • There is also the image-cache module if you need to explicitly cache some images https://docs.nativescript.org/api-reference/modules/_ui_image_cache_ – Nick Iliev May 22 '18 at 13:50
  • @NickIliev I want to cache some data not only images for offline view and for a better user experience :) – Jannomeister May 23 '18 at 04:50
  • There are a lot of ways to persist data .. e.g. using `application-settings` module or nativescript-sqlite plugin with SQLite or using nativescript-plugin-firebase with RealtimeDB and offline mode (persist property). – Nick Iliev May 23 '18 at 05:23

1 Answers1

0

you can use nativescript core module application-settings. it does exactly same as nativescript-cache plugin.

import {
    getBoolean,
    setBoolean,
    getNumber,
    setNumber,
    getString,
    setString,
    hasKey,
    remove,
    clear
} from "application-settings";

Set and get boolean value and provide default value in case it is not set

setBoolean("isTurnedOn", true);
this.isTurnedOn = getBoolean("isTurnedOn", true);

Set and get string value

setString("username", "Wolfgang");
this.username = getString("username");

Set and get numeric value.

setNumber("locationX", 54.321);
this.locationX = parseFloat(getNumber("locationX").toFixed(3));

Reading values that are not set before while providing default value

// will return "No string value" if there is no value for "noSuchKey"
this.someKey = getString("noSuchKey", "No string value");

for more information you can refer nativescript docs: https://docs.nativescript.org/angular/code-samples/application-settings

bhavin jalodara
  • 1,470
  • 9
  • 12