@@ -10,6 +10,48 @@ What does it do:
1010
1111The Client implements almost all api functions from thetvdb excepted the download in ZIP format
1212
13+ Usage:
14+ ------
15+
16+ ``` php
17+ use Moinax\TvDb\Client;
18+ $apiKey = 'YOURAPIKEY';
19+
20+ $tvdb = new Client("http://thetvdb.com", $apiKey);
21+ $tvdb->getSerie(75710);
22+ ```
23+
24+ Cache usage:
25+ ------------
26+
27+ To save bandwidth, reduce latency, or both of two, you can use a Http Client with caching features.
28+ The HTTP client use the If-Modified-Since header to fetch full content only if resource was modified. This saves bandwidth.
29+ The HTTP client also use a time to live parameter to completly avoid making request if resource was fresh enough. This reduce latency.
30+
31+ ``` php
32+ <?php
33+ use Moinax\TvDb\Http\Cache\FilesystemCache;
34+ use Moinax\TvDb\Http\CacheClient;
35+ use Moinax\TvDb\Client;
36+
37+ $ttl = 600;
38+ $apiKey = 'YOURAPIKEY';
39+
40+ $cache = new FilesystemCache(__DIR__ . '/cache');
41+ $httpClient = new CacheClient($cache, $ttl);
42+
43+ $tvdb = new Client("http://thetvdb.com", $apiKey);
44+ $tvdb->setHttpClient($httpClient);
45+
46+ $tvdb->getSerie(75710); //This request will fetch the resource online.
47+ $tvdb->getSerie(75710); //Cache content is fresh enough. We don't make any request.
48+ sleep(600);
49+ $tvdb->getSerie(75710); //The content is not fresh enough. We make a request with
50+ //the If-Modified-Since header. The server respond 304 Not
51+ //modified, so we load content from the cache.
52+ ```
53+
54+
1355Examples:
1456---------
1557
@@ -18,4 +60,4 @@ Rename the settings.php.dist in settings.php if you wan to test and enter your o
1860
1961Status:
2062-------
21- This version is quite stable and used in production on http://nextepisode.tv
63+ This version is quite stable and used in production on http://nextepisode.tv
0 commit comments