chore: move to once_cell from lazy_static
This commit is contained in:
@@ -9,6 +9,7 @@ use rocket::request::{FromRequest, Outcome};
|
||||
use schemars::schema::{InstanceType, SchemaObject, SingleOrVec};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
#[derive(Validate, Serialize, Deserialize)]
|
||||
pub struct IdempotencyKey {
|
||||
@@ -16,9 +17,7 @@ pub struct IdempotencyKey {
|
||||
key: String,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref TOKEN_CACHE: Mutex<lru::LruCache<String, ()>> = Mutex::new(lru::LruCache::new(100));
|
||||
}
|
||||
static TOKEN_CACHE: Lazy<Mutex<lru::LruCache<String, ()>>> = Lazy::new(|| Mutex::new(lru::LruCache::new(100)));
|
||||
|
||||
impl IdempotencyKey {
|
||||
// Backwards compatibility.
|
||||
|
||||
@@ -22,6 +22,7 @@ use revolt_rocket_okapi::request::{OpenApiFromRequest, RequestHeaderInput};
|
||||
use serde::Serialize;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
/// Ratelimit Bucket
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -30,9 +31,7 @@ struct Entry {
|
||||
reset: u128,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref MAP: DashMap<u64, Entry> = DashMap::new();
|
||||
}
|
||||
static MAP: Lazy<DashMap<u64, Entry>> = Lazy::new(|| DashMap::new());
|
||||
|
||||
/// Get the current time from Unix Epoch as a Duration
|
||||
fn now() -> Duration {
|
||||
|
||||
Reference in New Issue
Block a user