# buildKey(key)

### **Arguments**

1. `key` *(string)*: String to build a key of.

### **Lifecycle**

1. **preBuildKey**

   **Event name:** `preBuiltKey`\
   **Properties passed:**

   * `cacheInstance` reference to cache instance (`this`)
   * `key` key passed to `buildKey` method

   **Returns:** *(object)*: object containing properties:

   * `cacheInstance` reference to cache instance (`this`)
   * `key` key passed through handlers added for `preBuildKey` event<br>
2. **postBuildKey**

   **Event name:** `postBuiltKey`\
   **Properties passed:**

   * `cacheInstance` reference to cache instance (`this`) returned by `preBuildKey`
   * `key` key built by adapter using its [buildKey](https://stash-it.gitbook.io/stash-it/api/adapter/buildkey-key) method

   **Returns:** *(object)*: object containing properties:

   * `cacheInstance` reference to cache instance (`this`)
   * `key` key passed through handlers added for `postBuildKey` event

   \
   Eventually `buildKey` returns key returned by `postBuildKey`.

### **Returns**

*(string)*: Built key. Depends on adapter being used.

### **Example**

```javascript
// assuming that you already have cache instance prepared
const builtKey = cache.buildKey('key');
```
