Expand all

ve.init.ConflictableStorage

Conflict-safe storage extending a ve.init.SafeStorage instance

Implements conflict handling for localStorage: Any time the storage is used and it is detected that another process has modified the underlying data, all the managed keys are restored from an in-memory cache. There is no merging of data, all managed keys are either completely overwritten, or deleted if they were not originally set.

This would be namespaced ve.init.ConflictableStorage, but as a generated class it is never exported.

Methods

clearExpired() → {jQuery.Promise}abstractprotected #

Clear any expired items from the store

Inherited from:
Source:

Returns:

Resolves when items have been expired

Type
jQuery.Promise
Clear any expired items from the store

get(key) → {string|null|boolean}abstract #

Retrieve value from device storage.

Parameters:

Name Type Description
key string

Key of item to retrieve

Inherited from:
Source:

Returns:

String value, null if no value exists, or false if storage is not available.

Type
string | null | boolean
Retrieve value from device storage.

getExpiryKeys() → {jQuery.Promise}abstractprotected #

Get all keys with expiry values

Inherited from:
Source:

Returns:

Promise resolving with all the keys which have expiry values (unprefixed), or as many could be retrieved in the allocated time.

Type
jQuery.Promise
Get all keys with expiry values

getObject(key) → {Object|null|boolean}abstract #

Retrieve JSON object from device storage.

Parameters:

Name Type Description
key string

Key of item to retrieve

Inherited from:
Source:

Returns:

Object, null if no value exists or value is not JSON-parseable, or false if storage is not available.

Type
Object | null | boolean
Retrieve JSON object from device storage.

isExpired(key) → {boolean}abstractprotected #

Check if a given key has expired

Parameters:

Name Type Description
key string

Key name

Inherited from:
Source:

Returns:

Whether key is expired

Type
boolean
Check if a given key has expired

remove(key) → {boolean}abstract #

Remove a value from device storage.

Parameters:

Name Type Description
key string

Key of item to remove

Inherited from:
Source:

Returns:

Whether the save succeeded or not

Type
boolean
Remove a value from device storage.

set(key, value, [expiry]) → {boolean}abstract #

Set a value in device storage.

Parameters:

Name Type Attributes Description
key string

Key name to store under

value string

Value to be stored

expiry number optional

Number of seconds after which this item can be deleted

Inherited from:
Source:

Returns:

The value was set

Type
boolean
Set a value in device storage.

setExpires(key, [expiry])abstract #

Set the expiry time for an item in the store

Parameters:

Name Type Attributes Description
key string

Key name

expiry number optional

Number of seconds after which this item can be deleted, omit to clear the expiry (either making the item never expire, or to clean up when deleting a key).

Inherited from:
Source:
Set the expiry time for an item in the store

setObject(key, value, [expiry]) → {boolean}abstract #

Set an object value in device storage by JSON encoding

Parameters:

Name Type Attributes Description
key string

Key name to store under

value Object

Object value to be stored

expiry number optional

Number of seconds after which this item can be deleted

Inherited from:
Source:

Returns:

The value was set

Type
boolean
Set an object value in device storage by JSON encoding