Skip to content

Commit d487d25

Browse files
committed
Add global_cache_info
1 parent 5fe5dc6 commit d487d25

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/auxiliary/caches.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
const GLOBAL_CACHES = Any[]
1+
const GLOBAL_CACHES = Pair{Symbol,Any}[]
22
function empty_globalcaches!()
3-
foreach(empty!, GLOBAL_CACHES)
3+
foreach(empty! last, GLOBAL_CACHES)
44
return nothing
55
end
66

7+
function global_cache_info(io::IO=stdout)
8+
for (name, cache) in GLOBAL_CACHES
9+
println(io, name, ":\t", LRUCache.cache_info(cache))
10+
end
11+
end
12+
713
abstract type CacheStyle end
814
struct NoCache <: CacheStyle end
915
struct TaskLocalCache{D<:AbstractDict} <: CacheStyle end
@@ -140,7 +146,8 @@ macro cached(ex)
140146
fglobalcachedef = Expr(:const,
141147
Expr(:(=), globalcachename,
142148
:(LRU{Any,Any}(; maxsize=DEFAULT_GLOBALCACHE_SIZE[]))))
143-
fglobalcacheregister = Expr(:call, :push!, :GLOBAL_CACHES, globalcachename)
149+
fglobalcacheregister = Expr(:call, :push!, :GLOBAL_CACHES,
150+
:($(QuoteNode(globalcachename)) => $globalcachename))
144151

145152
# # total expression
146153
return esc(Expr(:block, _fex, newfex, fnocacheex, flocalcacheex,

0 commit comments

Comments
 (0)