21639: Use a more efficient data structure for the keep block cache
[arvados.git] / sdk / python / arvados / diskcache.py
index f8fca5780332e41ec1f894759b27df5c0bffd1a1..23c0a80cbfc0bd9c4f01e7f1dc152b8cbbfc65ff 100644 (file)
@@ -237,13 +237,13 @@ class DiskCacheSlot(object):
 
         # Map in all the files we found, up to maxslots, if we exceed
         # maxslots, start throwing things out.
-        cachelist = []
+        cachelist = collections.OrderedDict()
         for b in blocks:
             got = DiskCacheSlot.get_from_disk(b[0], cachedir)
             if got is None:
                 continue
             if len(cachelist) < maxslots:
-                cachelist.append(got)
+                cachelist[got.locator] = got
             else:
                 # we found more blocks than maxslots, try to
                 # throw it out of the cache.