Skip to content

Commit

Permalink
supply redis url with env var
Browse files Browse the repository at this point in the history
  • Loading branch information
snex committed Feb 15, 2023
1 parent 50ccf14 commit dbc64c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn generate_key() -> String {

fn add_key_to_redis(new_key: String, url: String) -> Option<()> {
let new_key = format!("xens:{}", new_key);
let client = redis::Client::open("redis://127.0.0.1/").ok()?;
let client = redis::Client::open(env::var("REDIS_URI").expect("REDIS_URI missing")).ok()?;
let mut con = client.get_connection().ok()?;
redis::pipe()
.atomic()
Expand Down Expand Up @@ -69,7 +69,7 @@ fn new_json(data: Json<UrlJson>) -> Value {

fn get_key_from_redis(key: String) -> Option<String> {
let key = format!("xens:{}", key);
let client = redis::Client::open("redis://127.0.0.1/").ok()?;
let client = redis::Client::open(env::var("REDIS_URI").expect("REDIS_URI missing")).ok()?;
let mut con = client.get_connection().ok()?;
redis::cmd("GET").arg(key).query(&mut con).ok()?
}
Expand Down

0 comments on commit dbc64c3

Please sign in to comment.