Key-Value Store
Custom Entity Store
SQL (EAP)
Cache (EAP)

Forge Cache is now available as part of Forge Early Access Program (EAP). To start testing this feature, sign up using this form.

Forge Cache is an experimental feature offered to selected users for testing and feedback purposes. This feature is unsupported and subject to change without notice. Do not use Forge Cache in apps that handle sensitive information and customer data.

For more details, see Forge EAP, Preview, and GA.

Error handling for Forge Cache

The @forge/cache package throws errors along with their error codes. The following example shows how to handle an error when the app tries to store a value that exceeds the maximum allowed size.

1
2
import { cache, errorCodes } from '@forge/cache'; 
try { 
  const cacheClient = cache.connect();
  await cacheClient.set("hello", 3, { ttlSeconds: 10 });
} 
catch (error) { 
  if (error.code === errorCodes.MAX_VALUE_SIZE_EXCEEDED) { 
    // Handle when value of key is above the max allowed value
  } 
} 
Error codeDescription
INVALID_KEY_TYPEThe provided key is not a string.
Ensure that you are passing a string value for the key.
MIN_VALID_KEY_LENGTH_REQUIREDThe provided key needs to be more than one character.
See the Forge Cache limits for more details.
INVALID_KEY_PATTERNThe provided key does not match the regular expression (regex).
Ensure that the key matches the regex: /^(?!\s+$)[a-zA-Z0-9:._\s-#]+$/
VALUE_IS_NOT_A_STRINGThe provided value is not a string type.
Ensure the provided type of value is a string.
VALUE_IS_REQUIREDThe provided value could not be found.
Ensure there is a provided value.
INVALID_VALUE_TYPEThe provided value is an invalid type type.
Ensure the provided type of value is a string.
MAX_VALUE_SIZE_EXCEEDEDThe provided value has exceeded the maximum valid size of 240 KiB.
See the Forge Cache limits for more details.
INVALID_LIMIT_VALUEThe provided limit value is invalid.
Ensure the provided value only contains digits and is between 30s and 3600s.
See the Forge Cache limits for more details.
Error codeDescription
VALUE_IS_NOT_A_STRINGThe provided value is not a string type.
VALUE_IS_REQUIREDEnsure there is a provided value.
INVALID_VALUE_TYPEThe provided value is an invalid type type.
Ensure the provided type of value is a string.
MAX_VALUE_SIZE_EXCEEDEDThe provided value has exceeded the maximum valid size of 240KiB.
See the Forge Cache limits for more details.
INVALID_LIMIT_VALUEThe provided limit value is invalid.
Ensure the provided value only contains digits and is between 30s and 3600s.
See the Forge Cache limits for more details.
Error codeDescription
INVALID_TTL_TYPEThe provided ttlSeconds is an invalid type.
Ensure the provided type of value is an integer.
VALUE_IS_REQUIREDThe provided value could not be found. Ensure there is a provided value.
INVALID_VALUE_TYPEThe provided value is an invalid type type.
Ensure the provided type of value is a string.
MAX_VALUE_SIZE_EXCEEDEDThe provided value has exceeded the maximum valid size.
Ensure the provided value is under 240 KiB. See the Forge Cache limits for more details.
INVALID_LIMIT_VALUEThe provided limit value is invalid.
Ensure the provided value only contains digits and is between 30s and 3600s. See the Forge Cache limits for more details.

Rate this page: