-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
It would be great if there was an option to cache API requests. Sometimes on large import it throws an error after a certain amount of time. Also API requests for most of these service desks are rate limited - for example Zendesk only allows 10 requests per minute! If the requests were cached on the file system it would make the next try quicker to pick up where it left off. Right now I am using something like this in my ApiController.
protected function getCached($url)
{
$root = $_SERVER['DOCUMENT_ROOT'].'/importer-cache/tickets/';
$filename = sha1($url);
if (!property_exists($this, 'getCachedFiles')) {
if (!file_exists($root)) {
mkdir($root, 0777, true);
}
$this->getCachedFiles = scandir($root);
}
if (in_array($filename, $this->getCachedFiles)) {
$packet = file_get_contents($root.$filename);
} else {
$packet = $this->get($url);
file_put_contents($root.$filename, $packet);
}
return $packet;
}
If there was a way to clear the cache that would be good too. And a way to reset the state of Awesome Support (delete all posts and all associated postmeta) just for the purposes of resetting an import.
Metadata
Metadata
Assignees
Labels
No labels