Skip to content

Commit

Permalink
Fix url short term cache for legacy trans object
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Sep 30, 2024
1 parent bfbca74 commit cd19148
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 10 additions & 0 deletions lib/galaxy/managers/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@
import string
from json import dumps
from typing import (
Any,
Callable,
cast,
Dict,
List,
Optional,
Tuple,
)

from sqlalchemy import select
Expand Down Expand Up @@ -204,6 +207,13 @@ class ProvidesUserContext(ProvidesAppContext):

galaxy_session: Optional[GalaxySession] = None
_tag_handler: Optional[GalaxyTagHandlerSession] = None
_short_term_cache: Dict[Tuple[str, ...], Any]

def set_cache_value(self, args: Tuple[str, ...], value: Any):
self._short_term_cache[args] = value

def get_cache_value(self, args: Tuple[str, ...], default: Any = None) -> Any:
return self._short_term_cache.get(args, default)

@property
def tag_handler(self):
Expand Down
2 changes: 2 additions & 0 deletions lib/galaxy/webapps/base/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Any,
Dict,
Optional,
Tuple,
)
from urllib.parse import urlparse

Expand Down Expand Up @@ -325,6 +326,7 @@ def __init__(
self.galaxy_session = None
self.error_message = None
self.host = self.request.host
self._short_term_cache: Dict[Tuple[str, ...], Any] = {}

# set any cross origin resource sharing headers if configured to do so
self.set_cors_headers()
Expand Down
6 changes: 0 additions & 6 deletions lib/galaxy/work/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ def __init__(
self.workflow_building_mode = workflow_building_mode
self.galaxy_session = galaxy_session

def set_cache_value(self, args: Tuple[str, ...], value: Any):
self._short_term_cache[args] = value

def get_cache_value(self, args: Tuple[str, ...], default: Any = None) -> Any:
return self._short_term_cache.get(args, default)

@property
def app(self):
return self._app
Expand Down

0 comments on commit cd19148

Please sign in to comment.