util.cache: Add method for iterating over values
[prosody.git] / util / cache.lua
index 074916cd6a1c2f6ad41ba392204e560ad7798d03..54f3e10b175055a85696dcbf5fc5040ad2d00028 100644 (file)
@@ -88,6 +88,18 @@ function cache_methods:items()
        end
 end
 
+function cache_methods:values()
+       local m = self._head;
+       return function ()
+               if not m then
+                       return;
+               end
+               local v = m.value;
+               m = m.next;
+               return v;
+       end
+end
+
 function cache_methods:count()
        return self._count;
 end