Class YAHOO.util.Storage
The Storage class is an HTML 5 storage API clone, used to wrap individual storage implementations with a common API.
Constructor
YAHOO.util.Storage
(
sLocation
,
oConf
)
- Parameters:
-
sLocation
<String>
Required. The storage location.
-
oConf
<Object>
Required. A configuration object.
Properties
_cfg
- protected {Object}
The configuration of the engine.
_location
- protected {String}
The location for this instance.
_name
- protected {String}
The event name for when the storage item has changed.
The event name for when the storage item is ready.
isReady
- protected {String}
This engine singleton has been initialized already.
The current length of the keys.
Methods
protected
void
_clear
(
)
Implementation of the clear login; should be overwritten by storage engine.
protected
void
_createValue
(
o
)
Converts the object into a string, with meta data (type), so it can be restored later.
- Parameters:
-
o
<Object>
Required. An object to store.
protected
String|NULL
_getItem
(
sKey
)
Implementation of the getItem login; should be overwritten by storage engine.
- Parameters:
-
sKey
<String>
Required. The key used to reference this value.
- Returns:
String|NULL
- The value stored at the provided key.
protected
void
_getValue
(
s
)
Converts the stored value into its appropriate type.
- Parameters:
-
s
<String>
Required. The stored value.
protected
String|NULL
_key
(
nIndex
)
Implementation of the key logic; should be overwritten by storage engine.
- Parameters:
-
nIndex
<Number>
Required. The index to retrieve (unsigned long in HTML 5 spec).
- Returns:
String|NULL
- Required. The key at the provided index (DOMString in HTML 5 spec).
protected
void
_removeItem
(
sKey
)
Implementation of the removeItem login; should be overwritten by storage engine.
- Parameters:
-
sKey
<String>
Required. The key to remove.
protected
Boolean
_setItem
(
sKey
,
oData
)
Implementation of the setItem login; should be overwritten by storage engine.
- Parameters:
-
sKey
<String>
Required. The key used to reference this value.
-
oData
<Object>
Required. The data to storage at key.
- Returns:
Boolean
- True when successful, false when size QUOTA exceeded.
void
clear
(
)
Clears any existing key/value pairs.
String|NULL
getItem
(
sKey
)
Fetches the data stored and the provided key.
- Parameters:
-
sKey
<String>
Required. The key used to reference this value (DOMString in HTML 5 spec).
- Returns:
String|NULL
- The value stored at the provided key (DOMString in HTML 5 spec).
String
getName
(
)
Fetches the storage object's name; should be overwritten by storage engine.
- Returns:
String
- The name of the data storage object.
Boolean
hasKey
(
sKey
)
Tests if the key has been set (not in HTML 5 spec); should be overwritten by storage engine.
- Parameters:
-
sKey
<String>
Required. The key to search for.
- Returns:
Boolean
- True when key has been set.
String
key
(
nIndex
)
Retrieve the key stored at the provided index; should be overwritten by storage engine.
- Parameters:
-
nIndex
<Number>
Required. The index to retrieve (unsigned long in HTML 5 spec).
- Returns:
String
- Required. The key at the provided index (DOMString in HTML 5 spec).
void
removeItem
(
sKey
)
Remove an item from the data storage.
- Parameters:
-
sKey
<String>
Required. The key to remove (DOMString in HTML 5 spec).
void
setItem
(
sKey
,
oData
)
Adds an item to the data storage.
- Parameters:
-
sKey
<String>
Required. The key used to reference this value (DOMString in HTML 5 spec).
-
oData
<Object>
Required. The data to store at key (DOMString in HTML 5 spec).