added disk cache expiration

This commit is contained in:
Arvid Norberg
2008-02-10 00:58:25 +00:00
parent cecd0dfcd2
commit 6c552db68e
7 changed files with 55 additions and 12 deletions

View File

@@ -146,6 +146,7 @@ namespace libtorrent
cache_status status() const;
void set_cache_size(int s);
void set_cache_expiry(int ex);
void operator()();
@@ -175,6 +176,7 @@ namespace libtorrent
std::vector<cached_piece_entry>::iterator find_cached_piece(
disk_io_job const& j, mutex_t::scoped_lock& l);
void flush_oldest_piece(mutex_t::scoped_lock& l);
void flush_expired_pieces(mutex_t::scoped_lock& l);
void flush_and_remove(std::vector<cached_piece_entry>::iterator i, mutex_t::scoped_lock& l);
void flush(std::vector<cached_piece_entry>::iterator i, mutex_t::scoped_lock& l);
void cache_block(disk_io_job& j, mutex_t::scoped_lock& l);
@@ -189,6 +191,8 @@ namespace libtorrent
int m_num_cached_blocks;
// in (16kB) blocks
int m_cache_size;
// expiration time of cache entries in seconds
int m_cache_expiry;
// memory pool for read and write operations
// and disk cache

View File

@@ -121,6 +121,7 @@ namespace libtorrent
, send_buffer_watermark(80 * 1024)
, auto_upload_slots(true)
, cache_size(512)
, cache_expiry(60)
{}
// this is the user agent that will be sent to the tracker
@@ -320,8 +321,13 @@ namespace libtorrent
bool auto_upload_slots;
// the disk write cache, specified in 16 KiB blocks.
// defaul is 512 (= 8 MB)
// default is 512 (= 8 MB)
int cache_size;
// the number of seconds a write cache entry sits
// idle in the cache before it's forcefully flushed
// to disk. Default is 60 seconds.
int cache_expiry;
};
#ifndef TORRENT_DISABLE_DHT