Adapter's methods

This is a brief description of methods. For detailed one, checkout adapters API.

buildKey(key)

It's responsible for building key.

You might ask, why there is such a method when you already provide a key? Well, this has been partially answered in namespaces and keys docs. But it will get clearer once you have a look at lifecycle of methods and plugins.

setItem(key, value, [extra])

It sets an item and returns it as well.

getItem(key)

It returns an item under a given key.

getExtra(key)

This method returns extra for given item under given key.

addExtra(key, extra)

This method adds extra for given item for given key. If item does not exist, it returns undefined. New properties (in extra) are added, existing are overwritten.

setExtra(key, extra)

This method sets (replaces existing) extra for given item for given key. If item does not exist, it returnsundefined.

hasItem(key)

This methods checks if item exists.

removeItem(key)

This method removes an item under given key.


Switching adapters, consistent interfaces

What is very important to remember: every single adapter will have, by default, all of those methods and they will behave exactly the same. Therefore you are guaranteed that if you switch adapters, your application won't break and will work exactly the same.

Heads up: the only difference is, when you switch adapters, storage, to which it connects, might not have the same capacity. But this is outside of the scope of responsibility of stash-it or adapters it uses.

Be sure to checkout stash-it-plugin-debug as it might come in handy.


results matching ""

    No results matching ""