Path: redb-route/redb.Route.Cache/CacheComponent.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Cache/CacheComponent.cs
----
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.Cache;
/// The cache: component: explicit get / put / remove / clear as endpoints (Camel cache-component analog).
[EndpointRole(EndpointRole.Producer, Hint = "Use it as To(\"cache:...\").")]
public sealed class CacheComponent : ComponentBase
{
///
public override string Scheme => "cache";
///
public override IEndpoint CreateEndpoint(EndpointUri uri)
{
ArgumentNullException.ThrowIfNull(uri);
var options = new CacheEndpointOptions();
options.BindFromUri(uri.RawParameters);
options.Validate();
return new CacheEndpoint(uri, this, options);
}
}
/// A cache:<region> endpoint; producer only.
public sealed class CacheEndpoint : EndpointBase
{
internal CacheEndpoint(EndpointUri uri, CacheComponent component, CacheEndpointOptions options)
: base(uri, component, options)
{
Region = string.IsNullOrWhiteSpace(uri.Path) ? "default" : uri.Path.Trim('/');
}
/// Region taken from the URI path (cache:customers → customers).
public string Region { get; }
///
public override IProducer CreateProducer() => new CacheProducer(this, Options);
///
public override IConsumer CreateConsumer(IProcessor processor)
=> throw new NotSupportedException("cache: endpoints are producers only (To(\"cache:...\")).");
}