Reading a public cache key
Reading a public cache does not require authentication. It's available to everyone.
The format is the following:
https://{your-project-name}.api.fireboost.io/v1/public-cache/get/{your-cache-key}
- The
{your-project-name}
is the name of the project you want to read from. - The
{your-cache-key}
is the key of the cache key you want to read.
You can in fact just use the browser to read a public cache key. Feel free to read our sandbox project's public cache key using your browser.
>> https://65113175.fireboost-stage.com/v1/public-cache/get/my-cache-key-1
You can also read it using cURL by sending a simple GET request.
curl -X 'GET' \
'https://65113175.fireboost-stage.com/v1/public-cache/get/my-cache-key-1' \
-H 'accept: application/json'
Public Read Request using the SDK
Using the official SDK is the recommended way to read a public cache key.
Reading your own public cache key is as simple as:
use FireboostIO\SDK\CacheManager;
use FireboostIO\SDK\Adapter\SessionAdapter;
// Create a CacheManager instance with default SessionAdapter
$apiKey = 'your-api-key'; // Or set FIREBOOST_API_KEY environment variable
$cacheManager = new CacheManager(new SessionAdapter(), $apiKey);
// Read public data (no authentication required)
$publicData = $cacheManager->readPublicCache($cacheKey);
Public Read Request using the libraries
Alternatively, you can use the libraries to read a public cache key. This would be the case if you want to use our official libraries but want to write your own SDK to interact with the API.
First, install the libraries:
composer require fireboostio/fireboost-php-auth
composer require fireboostio/fireboost-php-client
Then use the following code to read a public cache key:
use FireboostIO\Api\FireboostApi;
use FireboostIO\Configuration;
$config = new Configuration();
$config->setHost('https://{your-project-name}.api.fireboost.io');
$api = new FireboostApi(null, $config);
$cachekey = 'hello-from-cache';
$response = $api->getCache($cacheKey);
var_dump($response->getResult()[0]);
If you are considerin witing your own sdk you should considder joining our slack community.
Join our Slack community