So I'm trying to use this library for caching. https://github.com/php-cache/array-adapter
This is the sample code from documentation.
$pool = new ArrayCachePool();
$item = $pool->getItem('key')->set('datakkk');
$pool->save($item);
dd($pool->get('key'));
I want to store the token for some 3 minutes and if that token expires I want to make an auth API call. If it is not expired it will call the whatever endpoint it has provided.
I have done most of the part just I'm stuck between how to cache the token. Because it does get stored when I call the above code but it gets cleared for the next API call. Tried singletone pattern but it's not working. Any help would be appreciated.