mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user