40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/toaster/db/cgi_session_cache.rb', line 40
def by_obj_props(props_hash)
load_cache()
if DO_CACHE_QUERIES
props_str = props_hash.inspect
cached = @cache[KEY_QUERIES][props_str]
if cached
@hits << props_hash
return cached
end
end
if DO_CACHE_OBJECTS
@cache[KEY_OBJECTS] = [] if !@cache[KEY_OBJECTS]
puts "size: #{@cache[KEY_OBJECTS].size}"
objs = @cache[KEY_OBJECTS]
result = []
objs.each do |o|
arr = o.kind_of?(Array) ? o : [o]
all_match = true
arr.each do |item|
if !item || !matches(item, props_hash)
all_match = false
break
end
end
result << o if all_match
end
if result.size == 0
@misses << props_hash
return nil
end
@hits << props_hash
return result
end
@misses << props_hash
return nil
end
|