core/storagewrapper

Description:
  • 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

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

Methods

(inner) clean()

Description:
  • Clean local storage.

Source:

(inner) detectSupport() → {boolean}

Description:
  • Check if the browser supports the type of storage.

Source:
Returns:

True if the browser supports storage.

Type
boolean

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

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

Source:
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}

Description:
  • Hash a string, used to make shorter key prefixes.

Source:
Parameters:
Name Type Description
source String

The string to hash

Returns:
Type
Number

(inner) prefixKey(key) → {string}

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

Source:
Parameters:
Name Type Description
key string

The cache key to prefix.

Returns:

The new key

Type
string

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

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

Source:
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()

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

Source: