From 73816d03b3a5507d55f0ee977c91673129d2f414 Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Wed, 23 Aug 2023 00:20:08 +0530 Subject: [PATCH 1/2] Removed lifetime from transaction Fixed call site. --- src/client/client.rs | 2 +- src/client/transaction.rs | 52 +++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/client/client.rs b/src/client/client.rs index 810bf39..ba527ba 100644 --- a/src/client/client.rs +++ b/src/client/client.rs @@ -279,7 +279,7 @@ impl Client { /// Create a new transaction #[inline] pub fn create_transaction(&self) -> Transaction { - Transaction::new(self) + Transaction::new(self.clone()) } /// Create a new pipeline diff --git a/src/client/transaction.rs b/src/client/transaction.rs index f826418..29c117b 100644 --- a/src/client/transaction.rs +++ b/src/client/transaction.rs @@ -28,15 +28,15 @@ use crate::{ use std::{fmt, marker::PhantomData}; /// Represents an on-going [`transaction`](https://redis.io/docs/manual/transactions/) on a specific client instance. -pub struct Transaction<'a> { - client: &'a Client, +pub struct Transaction { + client: Client, commands: Vec, forget_flags: Vec, retry_on_error: Option, } -impl<'a> Transaction<'a> { - pub(crate) fn new(client: &'a Client) -> Self { +impl Transaction { + pub(crate) fn new(client: Client) -> Self { Self { client, commands: vec![cmd("MULTI")], @@ -262,7 +262,7 @@ where } } -impl<'a, 'b, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut Transaction<'b>, R> { +impl<'a, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut Transaction, R> { /// Queue a command into the transaction. fn queue(self) { self.executor.queue(self.command) @@ -274,42 +274,42 @@ impl<'a, 'b, R: Response> BatchPreparedCommand for PreparedCommand<'a, &'a mut T } } -impl<'a, 'b> BitmapCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> BitmapCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))] #[cfg(feature = "redis-bloom")] -impl<'a, 'b> BloomCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> BloomCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))] #[cfg(feature = "redis-bloom")] -impl<'a, 'b> CountMinSketchCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> CountMinSketchCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))] #[cfg(feature = "redis-bloom")] -impl<'a, 'b> CuckooCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> GenericCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> GeoCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> CuckooCommands<'a> for &'a mut Transaction {} +impl<'a> GenericCommands<'a> for &'a mut Transaction {} +impl<'a> GeoCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-graph")))] #[cfg(feature = "redis-graph")] -impl<'a, 'b> GraphCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> HashCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> HyperLogLogCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> GraphCommands<'a> for &'a mut Transaction {} +impl<'a> HashCommands<'a> for &'a mut Transaction {} +impl<'a> HyperLogLogCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-json")))] #[cfg(feature = "redis-json")] -impl<'a, 'b> JsonCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> ListCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> JsonCommands<'a> for &'a mut Transaction {} +impl<'a> ListCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-search")))] #[cfg(feature = "redis-search")] -impl<'a, 'b> SearchCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> SetCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> ScriptingCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> ServerCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> SortedSetCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> StreamCommands<'a> for &'a mut Transaction<'b> {} -impl<'a, 'b> StringCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> SearchCommands<'a> for &'a mut Transaction {} +impl<'a> SetCommands<'a> for &'a mut Transaction {} +impl<'a> ScriptingCommands<'a> for &'a mut Transaction {} +impl<'a> ServerCommands<'a> for &'a mut Transaction {} +impl<'a> SortedSetCommands<'a> for &'a mut Transaction {} +impl<'a> StreamCommands<'a> for &'a mut Transaction {} +impl<'a> StringCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))] #[cfg(feature = "redis-bloom")] -impl<'a, 'b> TDigestCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> TDigestCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-time-series")))] #[cfg(feature = "redis-time-series")] -impl<'a, 'b> TimeSeriesCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> TimeSeriesCommands<'a> for &'a mut Transaction {} #[cfg_attr(docsrs, doc(cfg(feature = "redis-bloom")))] #[cfg(feature = "redis-bloom")] -impl<'a, 'b> TopKCommands<'a> for &'a mut Transaction<'b> {} +impl<'a> TopKCommands<'a> for &'a mut Transaction {} From 880f6642294768007d1ae25fa2ed9d3623e39059 Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Wed, 23 Aug 2023 02:33:36 +0530 Subject: [PATCH 2/2] Made docker commands more backwards compatible --- redis/cluster-entrypoint.sh | 0 redis/cluster.dockerfile | 2 +- redis/docker_down.cmd | 2 +- redis/docker_down.sh | 2 +- redis/docker_up.cmd | 2 +- redis/docker_up.sh | 2 +- redis/sentinel-entrypoint.sh | 0 redis/sentinel.dockerfile | 2 +- redis/set_host_ip.sh | 0 9 files changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 redis/cluster-entrypoint.sh mode change 100644 => 100755 redis/docker_down.sh mode change 100644 => 100755 redis/docker_up.sh mode change 100644 => 100755 redis/sentinel-entrypoint.sh mode change 100644 => 100755 redis/set_host_ip.sh diff --git a/redis/cluster-entrypoint.sh b/redis/cluster-entrypoint.sh old mode 100644 new mode 100755 diff --git a/redis/cluster.dockerfile b/redis/cluster.dockerfile index fdb333b..17ff764 100644 --- a/redis/cluster.dockerfile +++ b/redis/cluster.dockerfile @@ -5,5 +5,5 @@ WORKDIR /redis COPY cluster.conf . RUN chown redis:redis /redis/cluster.conf EXPOSE 6379 -COPY --chmod=755 cluster-entrypoint.sh . +COPY cluster-entrypoint.sh . ENTRYPOINT ["/redis/cluster-entrypoint.sh"] \ No newline at end of file diff --git a/redis/docker_down.cmd b/redis/docker_down.cmd index 657b47a..c3af056 100644 --- a/redis/docker_down.cmd +++ b/redis/docker_down.cmd @@ -1,3 +1,3 @@ @echo off call set_host_ip.cmd -docker compose down +docker-compose down diff --git a/redis/docker_down.sh b/redis/docker_down.sh old mode 100644 new mode 100755 index 648ef7d..04a2458 --- a/redis/docker_down.sh +++ b/redis/docker_down.sh @@ -1,2 +1,2 @@ ./set_host_ip.sh -docker compose down \ No newline at end of file +docker-compose down \ No newline at end of file diff --git a/redis/docker_up.cmd b/redis/docker_up.cmd index 54b7249..5506eb8 100644 --- a/redis/docker_up.cmd +++ b/redis/docker_up.cmd @@ -1,3 +1,3 @@ @echo off call set_host_ip.cmd -docker compose up -d \ No newline at end of file +docker-compose up -d \ No newline at end of file diff --git a/redis/docker_up.sh b/redis/docker_up.sh old mode 100644 new mode 100755 index 1b41941..b4606aa --- a/redis/docker_up.sh +++ b/redis/docker_up.sh @@ -1,2 +1,2 @@ sh ./set_host_ip.sh -docker compose up -d +docker-compose up -d diff --git a/redis/sentinel-entrypoint.sh b/redis/sentinel-entrypoint.sh old mode 100644 new mode 100755 diff --git a/redis/sentinel.dockerfile b/redis/sentinel.dockerfile index 77385b8..ee7c310 100644 --- a/redis/sentinel.dockerfile +++ b/redis/sentinel.dockerfile @@ -5,5 +5,5 @@ WORKDIR /redis COPY sentinel.conf . RUN chown redis:redis /redis/sentinel.conf EXPOSE 26379 -COPY --chmod=755 sentinel-entrypoint.sh . +COPY sentinel-entrypoint.sh . ENTRYPOINT ["/redis/sentinel-entrypoint.sh"] \ No newline at end of file diff --git a/redis/set_host_ip.sh b/redis/set_host_ip.sh old mode 100644 new mode 100755