Artwork caching (pull request #61), and also:

- introduced new section in config file for sqlite pragma settings,
added config for artwork cache
- added setting of pragma synchronous, cache size and journal mode to
daap cache
This commit is contained in:
chme
2014-11-10 22:53:08 +01:00
committed by ejurgensen
parent 61a4da215c
commit 7578bb1205
18 changed files with 2142 additions and 1197 deletions

View File

@@ -52,7 +52,7 @@
#include "httpd_daap.h"
#include "daap_query.h"
#include "dmap_common.h"
#include "daap_cache.h"
#include "cache.h"
#ifdef HAVE_LIBEVENT2
# include <event2/http_struct.h>
@@ -2255,9 +2255,9 @@ daap_reply_extra_data(struct evhttp_request *req, struct evbuffer *evbuf, char *
}
if (strcmp(uri[2], "groups") == 0)
ret = artwork_get_group(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf);
ret = artwork_get_group(id, max_w, max_h, evbuf);
else if (strcmp(uri[2], "items") == 0)
ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf);
ret = artwork_get_item(id, max_w, max_h, evbuf);
switch (ret)
{
@@ -2668,19 +2668,6 @@ daap_request(struct evhttp_request *req)
*/
evhttp_add_header(headers, "Content-Type", "application/x-dmap-tagged");
// Try the cache
evbuf = daapcache_get(full_uri);
if (evbuf)
{
httpd_send_reply(req, HTTP_OK, "OK", evbuf); // TODO not all want this reply
evbuffer_free(evbuf);
free(uri);
free(full_uri);
return;
}
// No cache, so prepare handler arguments and send to the handler
evbuf = evbuffer_new();
if (!evbuf)
{
@@ -2693,6 +2680,19 @@ daap_request(struct evhttp_request *req)
return;
}
// Try the cache
ret = cache_daap_get(full_uri, evbuf);
if (ret == 0)
{
httpd_send_reply(req, HTTP_OK, "OK", evbuf); // TODO not all want this reply
evbuffer_free(evbuf);
free(uri);
free(full_uri);
return;
}
// No cache, so prepare handler arguments and send to the handler
evhttp_parse_query(full_uri, &query);
clock_gettime(CLOCK_MONOTONIC, &start);
@@ -2705,8 +2705,8 @@ daap_request(struct evhttp_request *req)
DPRINTF(E_DBG, L_DB, "DAAP request handled in %d milliseconds\n", msec);
if (msec > daapcache_threshold())
daapcache_add(full_uri, ua, msec);
if (msec > cache_daap_threshold())
cache_daap_add(full_uri, ua, msec);
evhttp_clear_headers(&query);
evbuffer_free(evbuf);