Skip to content

Commit 1126c5e

Browse files
committed
ALlow emptying of cache on recoplan
1 parent 23a877c commit 1126c5e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/RecoPlans/Cache.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ end
115115

116116
"""
117117
empty!(cache::ProcessResultCache)
118+
empty!(plan::RecoPlan{ProcessResultCache})
118119
119120
Empty the cache of the `ProcessResultCache`
120121
"""
121-
Base.empty!(cache::ProcessResultCache) = empty!(cache.cache)
122+
Base.empty!(cache::Union{ProcessResultCache, RecoPlan{<:ProcessResultCache}}) = empty!(cache.cache)
122123
"""
123124
resize!(cache::ProcessResultCache)
124125

test/caching.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,24 @@
171171

172172
@testset "RecoPlan" begin
173173
cache_misses = Ref(0)
174-
cached_parameter = CacheableParameter(3, cache_misses)
174+
cached_parameter = PureCacheableParameter(3, cache_misses)
175175
cache = ProcessResultCache(; param = cached_parameter, maxsize = 1)
176176

177177
plan = toPlan(cache)
178178
setAll!(plan, :maxsize, 3)
179179
@test plan.cache.maxsize == 3
180180

181-
clear!(plan.param)
181+
process(CacheableAlgorithm, cache, 42)
182+
@test length(keys(cache.cache)) == 1
183+
empty!(cache)
184+
@test length(keys(cache.cache)) == 0
185+
process(CacheableAlgorithm, cache, 42)
186+
@test plan.cache == cache.cache
187+
@test length(keys(cache.cache)) == 1
188+
empty!(plan)
189+
@test length(keys(cache.cache)) == 0
190+
191+
clear!(plan)
182192
io = IOBuffer()
183193
toTOML(io, plan)
184194
seekstart(io)

0 commit comments

Comments
 (0)