Skip to content

Latest commit

 

History

History
190 lines (141 loc) · 4.25 KB

KvStoreItemApi.md

File metadata and controls

190 lines (141 loc) · 4.25 KB

Fastly.KvStoreItemApi

const apiInstance = new Fastly.KvStoreItemApi();

Methods

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
deleteKeyFromStore DELETE /resources/stores/kv/{store_id}/keys/{key_name} Delete kv store item.
getKeys GET /resources/stores/kv/{store_id}/keys List kv store keys.
getValueForKey GET /resources/stores/kv/{store_id}/keys/{key_name} Get the value of an kv store item
setValueForKey PUT /resources/stores/kv/{store_id}/keys/{key_name} Insert an item into an kv store

deleteKeyFromStore

deleteKeyFromStore({ store_id, key_name })

Delete an item from an kv store

Example

const options = {
  store_id: "store_id_example", // required
  key_name: "key_name_example", // required
};

apiInstance.deleteKeyFromStore(options)
  .then(() => {
    console.log('API called successfully.');
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
store_id String
key_name String

Return type

null (empty response body)

getKeys

getKeys({ store_id, [cursor, ][limit, ][prefix, ][consistency] })

List the keys of all items within an kv store.

Example

const options = {
  store_id: "store_id_example", // required
  cursor: "cursor_example",
  limit: 100,
  prefix: "prefix_example",
  consistency: "consistency_example",
};

apiInstance.getKeys(options)
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
store_id String
cursor String [optional]
limit Number [optional] [defaults to 100]
prefix String [optional]
consistency String [optional]

Return type

InlineResponse2004

getValueForKey

getValueForKey({ store_id, key_name })

Get the value associated with a key.

Example

const options = {
  store_id: "store_id_example", // required
  key_name: "key_name_example", // required
};

apiInstance.getValueForKey(options)
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
store_id String
key_name String

Return type

Blob

setValueForKey

setValueForKey({ store_id, key_name, [if_generation_match, ][time_to_live_sec, ][metadata, ][add, ][append, ][prepend, ][background_fetch, ][body] })

Set a new value for a new or existing key in an kv store.

Example

const options = {
  store_id: "store_id_example", // required
  key_name: "key_name_example", // required
  if_generation_match: 56,
  time_to_live_sec: 56,
  metadata: "metadata_example",
  add: true,
  append: true,
  prepend: true,
  background_fetch: true,
  body: null,
};

apiInstance.setValueForKey(options)
  .then((data) => {
    console.log(data, "API called successfully.");
  })
  .catch((error) => {
    console.error(error);
  });

Options

Name Type Description Notes
store_id String
key_name String
if_generation_match Number [optional]
time_to_live_sec Number [optional]
metadata String [optional]
add Boolean [optional]
append Boolean [optional]
prepend Boolean [optional]
background_fetch Boolean [optional]
body Blob [optional]

Return type

Blob

[Back to top] [Back to API list] [Back to README]