Keys

Now that you know a bit about namespaces it's time to learn about keys.

Can I use anything as a key?

Well, it depends on the adapter. Why? It's all about how adapter can 'write' a key for it's storage.

For instance, memory adapter writes all keys as object properties:

// if you take a look inside memory adapter you will find
const data = {};

// so if you will set item using 'key' key and 'namespace' namespace, constructed key
// will be 'namespace.key' and if you store some string in there you will get:
{
    'namespace.key': 'some value'
}

Each adapter is responsible for generating keys and is responsible for validating them. If some characters are restricted and can't be used ... well, you just won't be able to use them.

Detailed information about keys can be found in each adapter.

Key is being built?

Yes. Again, key is being built using buildKey public method and building of a key also depends on the adapter. In combination with namespace it's used to avoid overwriting items stored under the same key. Head back to Namespaces to learn more.

results matching ""

    No results matching ""