From bff1fd3770675e31143235069218bb96aec3f0b8 Mon Sep 17 00:00:00 2001 From: Linas Juskevicius Date: Thu, 18 Aug 2022 11:48:22 +0300 Subject: [PATCH] Docs on cache busting --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index c4e858f..f3e379d 100644 --- a/README.md +++ b/README.md @@ -285,6 +285,24 @@ require 'routemaster/drain/caching_busting' $app = Routemaster::Drain::CachingBusting.new ``` +### Bust Cache for a URL + +If a service updates its `_links` one needs to clear caches to force URL +discovery. Run this (e.g. as a one-off in Hopper): + +```ruby +url = ENV['MY_SERVICE_URL'] +cache = Routemaster::Cache.new +cache.invalidate(url) +cache.bust(url) +``` + +Note that the URL has to match exactly. For example, `/` suffix would need to be busted separately. + +The links are also stored as a class variable in the running Ruby processes. +You need to restart them, too. You can restart just the affected services or +the whole app. + ## HTTP Client The Drain is using a Faraday http client for communication between services. The client comes with a convenient caching mechanism as a default and supports custom response materialization.