diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 138a5e6e63ee5fa39bcbc50c87759e19513126ed..9d13b56104de7487f1e461effefe736d0a67abf6 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -242,6 +242,32 @@ class Cache {
 		$query->execute(array($entry['fileid']));
 	}
 
+	/**
+	 * Move a file or folder in the cache
+	 *
+	 * @param string $source
+	 * @param string $target
+	 */
+	public function move($source, $target) {
+		$sourceId = $this->getId($source);
+		$newParentId = $this->getParentId($target);
+
+		//find all child entries
+		$query = \OC_DB::prepare('SELECT `path`, `fileid` FROM `*PREFIX*filecache` WHERE `path` LIKE ?');
+		$result = $query->execute(array($source . '/%'));
+		$childEntries = $result->fetchAll();
+		$sourceLength = strlen($source);
+		$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ? WHERE `fileid` = ?');
+
+		foreach ($childEntries as $child) {
+			$targetPath = $target . substr($child['path'], $sourceLength);
+			$query->execute(array($targetPath, md5($targetPath), $child['fileid']));
+		}
+
+		$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =? WHERE `fileid` = ?');
+		$query->execute(array($target, md5($target), $newParentId, $sourceId));
+	}
+
 	/**
 	 * remove all entries for files that are stored on the storage from the cache
 	 */
@@ -296,8 +322,7 @@ class Cache {
 	/**
 	 * search for files by mimetype
 	 *
-	 * @param string $part1
-	 * @param string $part2
+	 * @param string $mimetype
 	 * @return array
 	 */
 	public function searchByMime($mimetype) {
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 4f22e9bd1d940bd07dab2d974e3cc411de522dbf..9c469aa93741d6dab809a40ac1c19d40e062ce1a 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -149,6 +149,32 @@ class Cache extends \UnitTestCase {
 		$this->assertEquals(2, count($this->cache->searchByMime('foo/file')));
 	}
 
+	function testMove() {
+		$file1 = 'folder';
+		$file2 = 'folder/bar';
+		$file3 = 'folder/foo';
+		$file4 = 'folder/foo/1';
+		$file5 = 'folder/foo/2';
+		$data = array('size' => 100, 'mtime' => 50, 'mimetype' => 'foo/bar');
+
+		$this->cache->put($file1, $data);
+		$this->cache->put($file2, $data);
+		$this->cache->put($file3, $data);
+		$this->cache->put($file4, $data);
+		$this->cache->put($file5, $data);
+
+		$this->cache->move('folder/foo', 'folder/foobar');
+
+		$this->assertFalse($this->cache->inCache('folder/foo'));
+		$this->assertFalse($this->cache->inCache('folder/foo/1'));
+		$this->assertFalse($this->cache->inCache('folder/foo/2'));
+
+		$this->assertTrue($this->cache->inCache('folder/bar'));
+		$this->assertTrue($this->cache->inCache('folder/foobar'));
+		$this->assertTrue($this->cache->inCache('folder/foobar/1'));
+		$this->assertTrue($this->cache->inCache('folder/foobar/2'));
+	}
+
 	public function tearDown() {
 		$this->cache->clear();
 	}