new LocalStorageWrapper(namespace)
Helper object for interfacing with the LocalStorage. The LocalStorage
browser API allows for offline storage. That API is very unsophisticated,
and is essentially a lame key-value store. This object sits on top
and provides a number of useful utilities, including rudimentarycache
cache expiration.
This:
Parameters:
Name | Type | Description |
---|---|---|
namespace |
String | A namespace to use in grouping access to localstorage. This keeps access clean and organized, while also making it possible to have multiple LocalStorage connections. |
- Source:
Methods
get(key)
A method for retrieving the value associated with the given key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The name of the key to retrieve the value for. |
- Source:
has(key)
A test for whether the given key is in LocalStorage.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key to test existence for. |
- Source:
is_new(key, server_time)
A test for whether the server has the newer version. This function
assumes that the server trip takes about 5 seconds. This method
is largely deprecated.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The key to check. |
server_time |
Integer | The server's time as an epoch (in milliseconds) |
- Source:
remove(key)
A method for removing a key from LocalStorage.
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The name of the key to remove. |
- Source:
set(key, value)
A method for adding a key/value pair to LocalStorage.
Note that both parameters must be strings (JSON.stringify is your friend).
Parameters:
Name | Type | Description |
---|---|---|
key |
String | The name of the key. |
value |
String | The value. |
- Source: