Skip to content

Commit 29caa73

Browse files
committed
Add clear! to cache
1 parent 9c8bbfc commit 29caa73

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/RecoPlans/Cache.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ function process(algo::Union{A, Type{<:A}}, param::ProcessResultCache, inputs...
1313
return result
1414
end
1515

16+
function clear!(plan::RecoPlan{<:ProcessResultCache}, preserve::Bool = true)
17+
dict = getfield(plan, :values)
18+
set = getfield(plan, :setProperties)
19+
for key in keys(dict)
20+
value = dict[key]
21+
if typeof(value) <: RecoPlan && preserve
22+
clear!(value, preserve)
23+
else
24+
dict[key] = missing
25+
set[key] = false
26+
end
27+
end
28+
return plan
29+
end
30+
1631
function validvalue(plan, ::Type{T}, value::RecoPlan{<:ProcessResultCache}) where T
1732
innertype = value.param isa RecoPlan ? typeof(value.param).parameters[1] : typeof(value.param)
1833
return ProcessResultCache{<:innertype} <: T

0 commit comments

Comments
 (0)