1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// Copyright 2018-2026 Accenture Technology
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//! Process-wide holder of the cache's **single shared, multiplexed** backend
//! and the [`RedisCacheStore`] over it — Rust port of the Java `CacheRuntime`.
//! Every `v1.cache.redis` worker instance calls [`store`] and shares this one
//! connection: `redis.cache.instances` is worker concurrency, not a connection
//! count (design spec §4.4: no pool; the client pipelines over one in-order
//! connection).
//!
//! The backend is built **lazily on first use**, re-resolving configuration
//! on every attempt until it connects. This is deliberate (spec §6): the
//! function is registered before a credential-bootstrap application publishes
//! a vault password, and — unlike sync-over-async, which must keep an eager
//! Pub/Sub subscriber live — a cache has nothing to maintain at start-up and
//! **must not fail application start-up when Redis is briefly unreachable**.
//! While the connection cannot be built the store stays empty and each call
//! retries (a late credential is picked up); once built, the client owns
//! reconnection under it and the store is reused.
//!
//! The one connection is released on shutdown through the platform's
//! lifecycle ([`Platform::on_shutdown`]), registered from the build so the
//! cleanup is wired only when a connection has actually been opened.
use ;
use ;
use RedisBackend;
use crateCacheConfig;
use crateRedisCacheStore;
static STORE: = new;
/// Serializes the slow build so concurrent first callers open ONE connection
/// (the Java double-checked locking under a `ReentrantLock`).
static BUILD: Mutex = const_new;
/// The shared store, built on first use and reused thereafter. If the
/// connection cannot be built yet, the error propagates to the caller
/// (fail-fast — a cache failure is the caller's concern via the flow's
/// exception handler) and the next call retries with freshly resolved
/// configuration.
pub async
/// The store if one has been built (diagnostics; `None` before the first
/// successful call and after [`shutdown`]).
/// Install a store as the process-wide instance — the reuse/test seam (a store
/// built against an embedded or in-process server). Replaces any current one.
/// Release the shared backend (idempotent) — registered with
/// [`Platform::on_shutdown`] when the connection opens. Dropping the last
/// handle closes the connection; a later call rebuilds from live configuration.
async