1

I'm using PHP last.fm API to fetch artist image

I'd like to know how to cache the calls so that I don't need to make same call again and again. The API has facility to cache : DiskCache, SqliteCache but there is no documentation, could anyone please shed some light on it?

Below is my code :

<?php
require __DIR__ . "/src/lastfm.api.php";

// set api key
CallerFactory::getDefaultCaller()->setApiKey(LAST_FM_API_KEY);

// search for the Coldplay band
$artistName = "Coldplay";
$limit = 1;
$results = Artist::search($artistName, $limit);

echo "<ul>";
while ($artist = $results->current()) {
    echo "<li><div>";
    echo "Artist URL: " . $artist->getUrl() . "<br>";
    echo '<img src="' . $artist->getImage(4) . '">';
    echo "</div></li>";

    $artist = $results->next();
}
echo "</ul>";

?>
j0k
  • 22,600
  • 28
  • 79
  • 90
Sam
  • 81
  • 2
  • 8
  • 2
    There *is* documentation. I suppose you mean that there aren't examples: http://lastfm.felixbruns.de/php-last.fm-api/doc/php-lastfm-api/Cache.html – Álvaro González Dec 31 '12 at 10:27

0 Answers0