Skip to main content

Response objects from Momento APIs

These are the baseline responses for all commands. Some commands will add more data and functionality.

Commands fall generally into two categories. Those which respond with:

  1. Success or Error - An example is a Set operation. Either the item was successfully written to the cache or it errored.
  2. Hit, Miss, or Error - An example is a Get operation. If the requested item is in the cache, you have a cache Hit. If it is not in the cache, you get a cache Miss. If there is some sort of error, you get an Error.

Error

Returned in lieu of an exception.

Constructor

  • innerException: Exception - the exception which caused the error

Methods

  • message(): String - a human readable error message
  • innerException(): Exception - the original exception.
  • errorCode(): MomentoErrorCode - Momento’s own category of errors such as InvalidArgument or BadRequest. See Standards And Practices - Error Handling
  • toString(): String - alias for message()

Success

The command was successful.

Hit

The key or field exists in the cache. Usually extended to return a value.

Miss

The key or field does not exist in the cache.

Set

For TTL commands, the update was applied successfully.

NotSet

For TTL commands, the update was not applied and no change was made to the existing TTL.

Stored

For setIf* commands, the key did not exist and the value was set.

NotStored

For setIf* commands, the key existed and no value was set.