Skip to content

Commit

Permalink
Merge pull request #24812 from owncloud/fkammer-enhancement-cache-fol…
Browse files Browse the repository at this point in the history
…der-gc-ttl

Make chunk cache ttl configurable
  • Loading branch information
Vincent Petry committed May 25, 2016
2 parents 25f3110 + 51b0036 commit b5f455f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,14 @@
*/
'cache_path' => '',

/**
* TTL of chunks located in the cache folder before they're removed by
* garbage collection (in seconds). Increase this value if users have
* issues uploading very large files via the ownCloud Client as upload isn't
* completed within one day.
*/
'cache_chunk_gc_ttl' => 86400, // 60*60*24 = 1 day

/**
* Using Object Store with ownCloud
*/
Expand Down
10 changes: 9 additions & 1 deletion lib/private/legacy/filechunking.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class OC_FileChunking {
protected $info;
protected $cache;

/**
* TTL of chunks
*
* @var int
*/
protected $ttl;

static public function decodeName($name) {
preg_match('/(?P<name>.*)-chunking-(?P<transferid>\d+)-(?P<chunkcount>\d+)-(?P<index>\d+)/', $name, $matches);
return $matches;
Expand All @@ -41,6 +48,7 @@ static public function decodeName($name) {
*/
public function __construct($info) {
$this->info = $info;
$this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400);
}

public function getPrefix() {
Expand All @@ -67,7 +75,7 @@ protected function getCache() {
public function store($index, $data) {
$cache = $this->getCache();
$name = $this->getPrefix().$index;
$cache->set($name, $data);
$cache->set($name, $data, $this->ttl);

return $cache->size($name);
}
Expand Down

0 comments on commit b5f455f

Please sign in to comment.