Skip to content

Commit

Permalink
Functionality for purging a single image from the cache.
Browse files Browse the repository at this point in the history
For now, this image is selected at random, but a subtler method --
e.g. selecting the least-frequently-used image, or the image that
whose last-requested date is earliest -- should be developed soon.
  • Loading branch information
robmiller committed Apr 30, 2012
1 parent 337ee89 commit e1ddf3f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions expurgate.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ function($size, $cache) {
// Removes one image from the cache. This means that, when the cache is full,
// we'll be adopting a one in, one out policy
function purge_cache() {
$cache_files = get_cache_files();

// For now, select a file at random.
$to_delete = $cache_files[array_rand($cache_files)];

unlink(CACHE_DIR . '/' . $to_delete->filename);
}

// Removes expired entries from the cache.
Expand Down

0 comments on commit e1ddf3f

Please sign in to comment.