core/storagewrapper

Wrap an instance of the browser's local or session storage to handle cache expiry, key namespacing and other helpful things.

Source:
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Methods

(inner) detectSupport() → {boolean}

Source:

Check if the browser supports the type of storage.

Returns:

True if the browser supports storage.

Type
boolean

(inner) get(key) → {boolean|string}

Source:

Get a value from local storage. Remember - all values must be strings.

Parameters:
Name Type Description
key string

The cache key to check.

Returns:

False if the value is not in the cache, or some other error - a string otherwise.

Type
boolean | string

(inner) hashString(source) → {Number}

Source:

Hash a string, used to make shorter key prefixes.

Parameters:
Name Type Description
source String

The string to hash

Returns:
Type
Number

(inner) prefixKey(key) → {string}

Source:

Add a unique prefix to all keys so multiple moodle sites do not share caches.

Parameters:
Name Type Description
key string

The cache key to prefix.

Returns:

The new key

Type
string

(inner) set(key, value) → {boolean}

Source:

Set a value to local storage. Remember - all values must be strings.

Parameters:
Name Type Description
key string

The cache key to set.

value string

The value to set.

Returns:

False if the value can't be saved in the cache, or some other error - true otherwise.

Type
boolean

(inner) validateCache()

Source:

Check the current jsrev version and clear the cache if it has been bumped.