File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -5,19 +5,27 @@ local merger = require('merger')
5
5
6
6
local SELECT_FUNC_NAME = ' _crud.select_on_storage'
7
7
8
- -- TODO: implement key_def cache
8
+ local key_def_cache = {}
9
+ setmetatable (key_def_cache , {__mode = ' k' })
10
+
9
11
local function get_key_def (replicasets , space_name , index_name )
10
12
-- Get requested and primary index metainfo.
11
13
local conn = select (2 , next (replicasets )).master .conn
12
14
local primary_index = conn .space [space_name ].index [0 ]
13
15
local index = conn .space [space_name ].index [index_name ]
14
16
17
+ if key_def_cache [index ] ~= nil then
18
+ return key_def_cache [index ]
19
+ end
20
+
15
21
-- Create a key def.
16
22
local key_def = key_def_lib .new (index .parts )
17
23
if not index .unique then
18
24
key_def = key_def :merge (key_def_lib .new (primary_index .parts ))
19
25
end
20
26
27
+ key_def_cache [index ] = key_def
28
+
21
29
return key_def
22
30
end
23
31
You can’t perform that action at this time.
0 commit comments