Skip to content

Commit

Permalink
Add configurable cache to all_transactions (#2198)
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 authored Aug 29, 2024
1 parent 99302be commit 64c7590
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion safe_transaction_service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.8.1"
__version__ = "5.8.2"
__version_info__ = tuple(
int(num) if num.isdigit() else num
for num in __version__.replace("-", ".", 1).split(".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from datetime import timedelta
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union

from django.conf import settings
from django.db.models import QuerySet
from django.utils import timezone

Expand Down Expand Up @@ -57,6 +58,7 @@ class TransactionService:
def __init__(self, ethereum_client: EthereumClient, redis: Redis):
self.ethereum_client = ethereum_client
self.redis = redis
self.cache_expiration = settings.CACHE_ALL_TXS_VIEW

# Cache methods ---------------------------------
def get_cache_key(self, safe_address: str, tx_id: str):
Expand Down Expand Up @@ -100,7 +102,7 @@ def store_txs_in_cache(
pipe = self.redis.pipeline()
pipe.mset(to_store)
for key in to_store.keys():
pipe.expire(key, 60 * 60) # Expire in one hour
pipe.expire(key, self.cache_expiration)
pipe.execute()

# End of cache methods ----------------------------
Expand Down

0 comments on commit 64c7590

Please sign in to comment.