Changeset

5053:375ab71e4b37

moduleapi: If path name ends with '-cache' create table as weak (keys and values)
author Matthew Wild <mwild1@gmail.com>
date Mon, 30 Jul 2012 00:40:02 +0100
parents 5052:f1157cce5d7a
children 5054:97385c45e670
files core/moduleapi.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/moduleapi.lua	Sun Jul 29 22:21:58 2012 +0200
+++ b/core/moduleapi.lua	Mon Jul 30 00:40:02 2012 +0100
@@ -155,6 +155,9 @@
 		local shared = shared_data[path];
 		if not shared then
 			shared = {};
+			if path:match("%-cache$") then
+				setmetatable(shared, { __mode = "kv" });
+			end
 			shared_data[path] = shared;
 		end
 		t_insert(data_array, shared);
@@ -336,4 +339,4 @@
 	return io.open(path, mode);
 end
 
-return api;
\ No newline at end of file
+return api;