Skip to content

Commit

Permalink
Merge pull request #1102 from girder/better-cache-hits
Browse files Browse the repository at this point in the history
Tile serving can bypass loading a source if it is in memory.
  • Loading branch information
manthey authored Apr 10, 2023
2 parents b070c94 + bec9674 commit bb67f56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

### Improvements
- Better cache handling with Etags ([#1097](../../pull/1097))
- Reduce duplicate computation of slow cached values ([#1100](../../pull/1100))
- Reduce duplicate computation of slow cached values ([#1100](../../pull/1100))

### Bug Fixes
- Tile serving can bypass loading a source if it is in memory ([#1102](../../pull/1102))

### Changes
- On the large image item page, guard against overflow ([#1096](../../pull/1096))
Expand Down
12 changes: 7 additions & 5 deletions girder/girder_large_image/models/image_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,19 @@ def _tileFromHash(cls, item, x, y, z, mayRedirect=False, **kwargs):
sourceClass = girder_tilesource.AvailableGirderTileSources[sourceName]
except TileSourceError:
return None
if '_' in kwargs:
kwargs = kwargs.copy()
kwargs.pop('_', None)
classHash = sourceClass.getLRUHash(item, **kwargs)
tileHash = sourceClass.__name__ + ' ' + classHash + ' ' + strhash(
classHash) + strhash(*(x, y, z), mayRedirect=mayRedirect, **kwargs)
sourceClass.__name__ + ' ' + classHash) + strhash(
*(x, y, z), mayRedirect=mayRedirect, **kwargs)
try:
if tileCacheLock is None:
tileData = tileCache[tileHash]
else:
# Checking this outside the lock is sufficient for the cache
# miss condition and faster
if tileHash not in tileCache:
return None
# It would be nice if we could test if tileHash was in
# tileCache, but memcached doesn't expose that functionaility
with tileCacheLock:
tileData = tileCache[tileHash]
tileMime = TileOutputMimeTypes.get(kwargs.get('encoding'), 'image/jpeg')
Expand Down

0 comments on commit bb67f56

Please sign in to comment.