mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 23:47:28 +00:00
fix
This commit is contained in:
@@ -390,9 +390,10 @@ impl HotObjectCache {
|
|||||||
/// Returns true if the key was found and removed, false otherwise.
|
/// Returns true if the key was found and removed, false otherwise.
|
||||||
async fn remove(&self, key: &str) -> bool {
|
async fn remove(&self, key: &str) -> bool {
|
||||||
let mut cache = self.cache.write().await;
|
let mut cache = self.cache.write().await;
|
||||||
if let Some((_, cached)) = cache.pop(key) {
|
if let Some(cached) = cache.pop(key) {
|
||||||
let current = self.current_size.load(Ordering::Relaxed);
|
let current = self.current_size.load(Ordering::Relaxed);
|
||||||
self.current_size.store(current.saturating_sub(cached.size), Ordering::Relaxed);
|
self.current_size
|
||||||
|
.store(current.saturating_sub(cached.size), Ordering::Relaxed);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -24,8 +24,7 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::storage::concurrency::{
|
use crate::storage::concurrency::{
|
||||||
ConcurrencyManager, GetObjectGuard,
|
ConcurrencyManager, GetObjectGuard, get_advanced_buffer_size, get_concurrency_aware_buffer_size,
|
||||||
get_concurrency_aware_buffer_size, get_advanced_buffer_size
|
|
||||||
};
|
};
|
||||||
use rustfs_config::{KI_B, MI_B};
|
use rustfs_config::{KI_B, MI_B};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -437,10 +436,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let high_concurrency_size = get_advanced_buffer_size(50 * MI_B as i64, base_buffer, false);
|
let high_concurrency_size = get_advanced_buffer_size(50 * MI_B as i64, base_buffer, false);
|
||||||
assert!(
|
assert!(high_concurrency_size <= base_buffer, "High concurrency should reduce buffer size");
|
||||||
high_concurrency_size <= base_buffer,
|
|
||||||
"High concurrency should reduce buffer size"
|
|
||||||
);
|
|
||||||
|
|
||||||
drop(guards);
|
drop(guards);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ use rustfs_utils::{
|
|||||||
use rustfs_zip::CompressionFormat;
|
use rustfs_zip::CompressionFormat;
|
||||||
use s3s::header::{X_AMZ_RESTORE, X_AMZ_RESTORE_OUTPUT_PATH};
|
use s3s::header::{X_AMZ_RESTORE, X_AMZ_RESTORE_OUTPUT_PATH};
|
||||||
use s3s::{S3, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, dto::*, s3_error};
|
use s3s::{S3, S3Error, S3ErrorCode, S3Request, S3Response, S3Result, dto::*, s3_error};
|
||||||
|
use std::convert::Infallible;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
@@ -132,7 +133,6 @@ use std::{
|
|||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{Arc, LazyLock},
|
sync::{Arc, LazyLock},
|
||||||
};
|
};
|
||||||
use std::convert::Infallible;
|
|
||||||
use time::{OffsetDateTime, format_description::well_known::Rfc3339};
|
use time::{OffsetDateTime, format_description::well_known::Rfc3339};
|
||||||
use tokio::{io::AsyncRead, sync::mpsc};
|
use tokio::{io::AsyncRead, sync::mpsc};
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
@@ -1645,9 +1645,10 @@ impl S3 for FS {
|
|||||||
if let Some(cached_data) = manager.get_cached(&cache_key).await {
|
if let Some(cached_data) = manager.get_cached(&cache_key).await {
|
||||||
debug!("Serving object from cache: {}", cache_key);
|
debug!("Serving object from cache: {}", cache_key);
|
||||||
|
|
||||||
|
let value = cached_data.clone();
|
||||||
// Build response from cached data
|
// Build response from cached data
|
||||||
let body = Some(StreamingBlob::wrap::<_, Infallible>(futures::stream::once(async move {
|
let body = Some(StreamingBlob::wrap::<_, Infallible>(futures::stream::once(async move {
|
||||||
Ok(bytes::Bytes::from((*cached_data).clone()))
|
Ok(bytes::Bytes::from((*value).clone()))
|
||||||
})));
|
})));
|
||||||
|
|
||||||
let output = GetObjectOutput {
|
let output = GetObjectOutput {
|
||||||
|
|||||||
Reference in New Issue
Block a user