summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
authorHorus2016-07-03 21:17:34 +0200
committerHorus2016-07-03 21:17:34 +0200
commitf95af4211bc24e5cf0b5b017c7d50113e4000968 (patch)
tree30c97d3dd2cbb99bfefa458dab27434a557f2611 /index.php
parentf5cf66b6929928fe5a4a6cf227f9a2f2195329e5 (diff)
downloadimap2rss-f95af4211bc24e5cf0b5b017c7d50113e4000968.tar.gz
Add caching.
Diffstat (limited to 'index.php')
-rw-r--r--index.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/index.php b/index.php
index b40b8e1..3daeb7e 100644
--- a/index.php
+++ b/index.php
@@ -1,11 +1,26 @@
<?php
+require_once __DIR__ . '/bootstrap.php';
+
$user = "feed@maxmail.xyz";
-$pass = "1234";
-$inbox = array("INBOX", "Trash");
+$pass = "1234abc";
+#$inbox = array("INBOX", "Trash");
+$inbox = array("INBOX");
$max_items = 10;
+$ttl = 60*60;
$mail = getMail($user, $pass, $inbox, $max_items);
$inbox_string = implode(",", $inbox);
-$feed = generate_feed($mail, $user, $inbox_string);
+$cache_key = md5($user . $inbox_string);
+$client = new Predis\Client('tcp://127.0.0.1:6379?database=2');
+
+$feed = $client->get('feed_' . $cache_key);
+if ( false !== $feed ) {
+ $feed = generate_feed($mail, $user, $inbox_string);
+ $client->set('feed_' . $cache_key, $feed);
+ $client->expire('feed_' . $cache_key, $ttl);
+}
+
+header("Content-type: application/rss+xml");
+echo $feed;