Ephemeral Exchange is a cross platform cache with a REST API and some useful SDK clients for various platforms. In this example I’ll look at how to use intents to preserve cache atomicity, and the code demo platform will be Apps Script.
You’ll need to register and create a boss key in the API console. That will allow you make access keys for the store.
Generate a boss key
First off we’ll need a writer key. For collaboration purposes you’d probably also create a reader and an updater, but we’ll just stick to a writer for this demo. To create access keys, you need a boss key. You can make one in the API console, or use an existing one, and copy it to use in your script.
Initialize the API
Add the library – it’s reference is
Check service is up if you want
Create a writer key
Write a data item
If you want to read it back normally, with no intention to update
But you can also read it back, with an intention to update it shortly
And it returns an intent key. Now no-one else but this access key and this intent key can update it for a short while
If you to write it you’ll get an error
Here’s what an error looks like
This time it will allow the update since we are passing the intent key as well
If you don’t have an intent key, then it means someone else is working through the process of updating, so you have to wait. When it rejected your request it also told you the time you’d need to wait to be sure the other guy was finished, or his lock expired.
Where to get it
To use the store console, just visit the console and login with your google ID. No other registration is required. See this documentation for how to use the API and Ephemeral Exchange for more info, examples and demos.