# Yahoo! UI Library

### Storage 2.8.1

Yahoo! UI Library > Storage > YAHOO.util.Storage
Search:
Filters Show Private Show Protected Show Deprecated

## 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 `( location , conf )`

Parameters:
  `location <String>` Required. The storage location.
  `conf <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 name of this engine.

#### CE_CHANGE - `{String}`

The event name for when the storage item has changed.

#### CE_READY - `{String}`

The event name for when the storage item is ready.

#### DELIMITER - `{String}`

The delimiter uesed between the data type and the data.

#### isReady - `protected {String}`

This engine singleton has been initialized already.

#### length - `{Number}`

The current length of the keys.

### Methods

#### _clear

`protected void _clear ( )`
Implementation of the clear login; should be overwritten by storage engine.

#### _createValue

`protected void _createValue ( s )`
Converts the object into a string, with meta data (type), so it can be restored later.

Parameters:
  `s <Object>` Required. An object to store.

#### _getItem

`protected String|NULL _getItem ( key )`
Implementation of the getItem login; should be overwritten by storage engine.

Parameters:
  `key <String>` Required. The key used to reference this value.

Returns: `String|NULL`
  The value stored at the provided key.

#### _getValue

`protected void _getValue ( s )`
Converts the stored value into its appropriate type.

Parameters:
  `s <String>` Required. The stored value.

#### _key

`protected String|NULL _key ( index )`
Implementation of the key logic; should be overwritten by storage engine.

Parameters:
  `index <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).

#### _removeItem

`protected void _removeItem ( key )`
Implementation of the removeItem login; should be overwritten by storage engine.

Parameters:
  `key <String>` Required. The key to remove.

#### _setItem

`protected Boolean _setItem ( key , data )`
Implementation of the setItem login; should be overwritten by storage engine.

Parameters:
  `key <String>` Required. The key used to reference this value.
  `data <Object>` Required. The data to storage at key.

Returns: `Boolean`
  True when successful, false when size QUOTA exceeded.

#### clear

`void clear ( )`
Clears any existing key/value pairs.

#### getItem

`String|NULL getItem ( key )`
Fetches the data stored and the provided key.

Parameters:
  `key <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).

#### getName

`String getName ( )`
Fetches the storage object's name; should be overwritten by storage engine.

Returns: `String`
  The name of the data storage object.

#### hasKey

`Boolean hasKey ( key )`
Tests if the key has been set (not in HTML 5 spec); should be overwritten by storage engine.

Parameters:
  `key <String>` Required. The key to search for.

Returns: `Boolean`
  True when key has been set.

#### key

`String key ( index )`
Retrieve the key stored at the provided index; should be overwritten by storage engine.

Parameters:
  `index <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).

#### setItem

`void setItem ( key )`
Remove an item from the data storage.

Parameters:
  `key <String>` Required. The key to remove (DOMString in HTML 5 spec).

Copyright © 2010 Yahoo! Inc. All rights reserved.