All Products
Search
Document Center

SuperApp:Cache

Last Updated:Oct 25, 2024

This topic describes the JavaScript APIs of WVStorage. You can refer to this topic when you create HTML5 apps or Miniapps. The JavaScript APIs of WVStorage provide data caching-related capabilities, such as adding a cache, deleting a cache, and clearing a cache.

WVStorage.setItem

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Stores data in a specified key in the local cache.

Input parameters

  • [string]key: the specified key in the cache.

  • [string]value: the value of the key.

Callback parameters

Parameters for the success callback:

  • No callback parameters exist.

Parameters for the failure callback:

  • [string]msg: the error message.

var params = {
  key: 'key',
  value: 'value'
};

window.WindVane.call('WVStorage', 'setItem', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.getItem

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Obtains the cached data for the specified key.

Input parameters

  • [string]key: the specified key.

Callback parameters

Parameters for the success callback:

  • [string]data: the content corresponding to the key.

Parameters for the failure callback:

  • [string]msg: the error message.

var params = {
  key: 'key'
};

window.WindVane.call('WVStorage', 'getItem', params, function(e) {
        alert('success: ' + JSON.stringify(e));
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.removeItem

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Deletes the cached data of the specified key.

Input parameters

  • [string]key: the specified key.

Callback parameters

Parameters for the success callback:

  • No callback parameters exist.

Parameters for the failure callback:

  • [string]msg: the error message.

var params = {
  key: 'key'
};

window.WindVane.call('WVStorage', 'removeItem', params, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.clearStorage

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Asynchronously clears the locally cached data.

Input parameters

  • No input parameters exist.

Callback parameters

Parameters for the success callback:

  • No callback parameters exist.

Parameters for the failure callback:

  • [string]msg: the error message.

window.WindVane.call('WVStorage', 'clearStorage', {}, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});

WVStorage.clearStorageSync

Note

This API is available only in WindVane Android 1.0.3.4 or later, WindVane iOS 2.1.4 or later.

Synchronously clears the locally cached data.

Input parameters

  • No input parameters exist.

Callback parameters

Parameters for the success callback:

  • No callback parameters exist.

Parameters for the failure callback:

  • [string]msg: the error message.

window.WindVane.call('WVStorage', 'clearStorageSync', {}, function(e) {
}, function(e) {
        alert('failure: ' + JSON.stringify(e));
});