DEV: Provide API for anonymous cache segments (#8455)

This can be used from a plugin that needs to establish something new in
the anonymous cache. For example `is_ie` for an internet explorer
plugin.
This commit is contained in:
Robin Ward
2019-12-05 14:57:18 -05:00
committed by GitHub
parent 2987a46f48
commit 532fea1460
2 changed files with 53 additions and 4 deletions

View File

@ -82,6 +82,13 @@ class Plugin::Instance
@idx = 0
end
def register_anonymous_cache_key(key, &block)
key_method = "key_#{key}"
add_to_class(Middleware::AnonymousCache, key_method, &block)
Middleware::AnonymousCache.cache_key_segments[key] = key_method
Middleware::AnonymousCache.compile_key_builder
end
def add_admin_route(label, location)
@admin_route = { label: label, location: location }
end