Skip to content

Commit

Permalink
Improve caching a bit
Browse files Browse the repository at this point in the history
Rewrite blobcache to use sqlite as backend store.
Add support for conditional gets in HTTP client (both modification time
and etag).
  • Loading branch information
andoma committed Oct 17, 2011
1 parent e3ac9de commit 014aa05
Show file tree
Hide file tree
Showing 22 changed files with 524 additions and 407 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ endif
SRCS-${CONFIG_EMU_THREAD_SPECIFICS} += src/arch/emu_thread_specifics.c

BUNDLES += resources/metadb
BUNDLES += resources/cachedb

#
# Misc support
Expand Down
11 changes: 11 additions & 0 deletions resources/cachedb/001.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE item (
stash TEXT,
k TEXT,
lastaccess INTEGER,
expiry INTEGER,
modtime INTEGER,
etag TEXT,
payload BLOB,
UNIQUE(k, stash) ON CONFLICT FAIL);

CREATE INDEX item_key_idx ON item(stash, k);
6 changes: 4 additions & 2 deletions src/api/lastfm.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ write_to_blobcache(const char *artist, struct artist_image_queue *q)
free(ai);
}

blobcache_put(artist, "lastfm.artist.images", blob, blobsize, 86400);
blobcache_put(artist, "lastfm.artist.images", blob, blobsize, 86400,
NULL, 0);
free(blob);
}

Expand All @@ -206,7 +207,8 @@ load_from_blobcache(const char *artist, prop_t *parent)
size_t size;
prop_t *p;

s0 = data = blobcache_get(artist, "lastfm.artist.images", &size, 1);
s0 = data = blobcache_get(artist, "lastfm.artist.images", &size, 1, 0,
NULL, NULL);
if(data == NULL)
return 0;

Expand Down
6 changes: 3 additions & 3 deletions src/backend/sid/sid.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ be_sid2player_play(const char *url0, media_pipe_t *mp,

void *player;
void *data;
struct fa_stat fs;
size_t size;


url0 += strlen("sidplayer:");
Expand All @@ -60,10 +60,10 @@ be_sid2player_play(const char *url0, media_pipe_t *mp,
*p++= 0;
subsong = atoi(p);

if((data = fa_quickload(url, &fs, NULL, errbuf, errlen)) == NULL)
if((data = fa_quickload(url, &size, NULL, errbuf, errlen, NULL)) == NULL)
return NULL;

player = sidcxx_load(data, fs.fs_size, subsong, errbuf, errlen);
player = sidcxx_load(data, size, subsong, errbuf, errlen);
free(data);
if(player == NULL)
return NULL;
Expand Down
Loading

0 comments on commit 014aa05

Please sign in to comment.