loolwsd/TileCache.cpp |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit 74dcec1d3fe28fcb47f9424c505d97c04c6e973b
Author: Henry Castro <hcas...@collabora.com>
Date:   Sat Jul 25 20:00:07 2015 -0400

    loolwsd: LRU expiry persistent cache
    
    When tile requests from the cache, update time stamp file
    so LRU tiles are removed.

diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 2ee9da7..2203653 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -31,6 +31,9 @@
 #include "LOOLProtocol.hpp"
 #include "TileCache.hpp"
 
+// 1 hour tile cache expired
+#define  TILE_EXPIRED 3600000000
+
 using Poco::DigestEngine;
 using Poco::DirectoryIterator;
 using Poco::File;
@@ -93,6 +96,16 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(int 
part, int width, int hei
         return nullptr;
 
     std::string fileName = dirName + "/" + cachedName;
+    File fileTile(fileName);
+
+    if ( fileTile.exists() )
+    {
+        Poco::Timestamp timeNow;
+        if ( timeNow - fileTile.getLastModified() > TILE_EXPIRED )
+            fileTile.remove();
+        else
+            fileTile.setLastModified(timeNow);
+    }
 
     std::unique_ptr<std::fstream> result(new std::fstream(fileName, 
std::ios::in));
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to