matrix_sdk/client/caches.rs
1// Copyright 2025 The Matrix.org Foundation C.I.C.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use matrix_sdk_base::ttl_cache::TtlCache;
16use ruma::api::client::discovery::get_authorization_server_metadata::msc2965::AuthorizationServerMetadata;
17use tokio::sync::RwLock;
18
19use super::ClientServerCapabilities;
20
21/// A collection of in-memory data that the `Client` might want to cache to
22/// avoid hitting the homeserver every time users request the data.
23pub(crate) struct ClientCaches {
24 /// Server capabilities, either prefilled during building or fetched from
25 /// the server.
26 pub(super) server_capabilities: RwLock<ClientServerCapabilities>,
27 pub(crate) server_metadata: tokio::sync::Mutex<TtlCache<String, AuthorizationServerMetadata>>,
28}