mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add cache size limit check to caching routes
This commit is contained in:
parent
8fb028149b
commit
1a8a3c5b1d
1 changed files with 7 additions and 2 deletions
|
@ -5,6 +5,7 @@ module Kemal
|
||||||
include HTTP::Handler
|
include HTTP::Handler
|
||||||
|
|
||||||
INSTANCE = new
|
INSTANCE = new
|
||||||
|
CACHED_ROUTES_LIMIT = 1024
|
||||||
property routes, cached_routes
|
property routes, cached_routes
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -33,7 +34,11 @@ module Kemal
|
||||||
|
|
||||||
route = @routes.find(lookup_path)
|
route = @routes.find(lookup_path)
|
||||||
|
|
||||||
@cached_routes[lookup_path] = route if route.found?
|
if route.found? && @cached_routes.size < CACHED_ROUTES_LIMIT
|
||||||
|
@cached_routes[lookup_path] = route
|
||||||
|
else
|
||||||
|
@cached_routes.clear
|
||||||
|
end
|
||||||
|
|
||||||
route
|
route
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue