1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

chore: address deprecations

This commit is contained in:
Rob Ede
2024-03-11 19:47:15 +00:00
parent cccda67c1e
commit 327cc9a549
3 changed files with 15 additions and 13 deletions

View File

@ -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);