Only clear cached_routes if there's a route

This commit is contained in:
Serdar Dogruyol 2018-09-17 09:51:56 +03:00
parent 1a8a3c5b1d
commit 4bb56d2376
1 changed files with 2 additions and 3 deletions

View File

@ -34,10 +34,9 @@ module Kemal
route = @routes.find(lookup_path)
if route.found? && @cached_routes.size < CACHED_ROUTES_LIMIT
if route.found?
@cached_routes.clear if @cached_routes.size == CACHED_ROUTES_LIMIT
@cached_routes[lookup_path] = route
else
@cached_routes.clear
end
route