mirror of
https://github.com/actix/examples
synced 2025-06-26 17:17:42 +02:00
chore: address deprecations
This commit is contained in:
@ -4,7 +4,7 @@ use actix_web::{
|
||||
HttpResponse, Responder,
|
||||
};
|
||||
use apalis::{prelude::*, redis::RedisStorage};
|
||||
use chrono::{Duration, Utc};
|
||||
use chrono::{TimeDelta, Utc};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{persistent_jobs::Email, ItemCache};
|
||||
@ -12,7 +12,7 @@ use crate::{persistent_jobs::Email, ItemCache};
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub(crate) struct CacheInsert {
|
||||
data: String,
|
||||
duration: u64,
|
||||
duration: u32,
|
||||
}
|
||||
|
||||
#[get("/cache")]
|
||||
@ -26,7 +26,7 @@ pub(crate) async fn cache_item(
|
||||
cache: Data<ItemCache>,
|
||||
web::Json(form): web::Json<CacheInsert>,
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let expires = Utc::now() + Duration::seconds(form.duration as i64);
|
||||
let expires = Utc::now() + TimeDelta::try_seconds(form.duration as i64).unwrap();
|
||||
|
||||
// insert into item cache
|
||||
cache.lock().unwrap().insert(form.data, expires);
|
||||
|
Reference in New Issue
Block a user