Skip to content

Commit ee5822b

Browse files
committed
options: move to memcached instead of default redis cache
I don't think I consciously made a decision to use Redis or not, but it's more favorable to use Memcached for this for sure.
1 parent 29060e9 commit ee5822b

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/sentry/options/store.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,10 @@ def get_cache(self, key, silent=False):
101101
if not silent:
102102
logger.warn(CACHE_FETCH_ERR, key.name, exc_info=True)
103103
value = None
104-
else:
105-
if key.ttl > 0:
106-
self._local_cache[cache_key] = _make_cache_value(key, value)
104+
105+
if value is not None and key.ttl > 0:
106+
self._local_cache[cache_key] = _make_cache_value(key, value)
107+
107108
return value
108109

109110
def get_local_cache(self, key, force_grace=False):

src/sentry/runner/initializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def bind_cache_to_option_store():
362362
# settings and/or configuration values. Those options should have been
363363
# loaded at this point, so we can plug in the cache backend before
364364
# continuing to initialize the remainder of the application.
365-
from sentry.cache import default_cache
365+
from django.core.cache import cache as default_cache
366366
from sentry.options import default_store
367367

368368
default_store.cache = default_cache

tests/sentry/options/test_manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from exam import fixture, around
66
from mock import patch
77
from django.conf import settings
8+
from django.core.cache.backends.locmem import LocMemCache
89

9-
from sentry.cache.redis import RedisCache
1010
from sentry.models import Option
1111
from sentry.options.store import OptionsStore
1212
from sentry.options.manager import (
@@ -19,9 +19,9 @@
1919
class OptionsManagerTest(TestCase):
2020
@fixture
2121
def store(self):
22-
return OptionsStore(
23-
cache=RedisCache()
24-
)
22+
c = LocMemCache('test', {})
23+
c.clear()
24+
return OptionsStore(cache=c)
2525

2626
@fixture
2727
def manager(self):

tests/sentry/options/test_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import pytest
88
from exam import before, fixture
99
from mock import patch
10+
from django.core.cache.backends.locmem import LocMemCache
1011

11-
from sentry.cache.redis import RedisCache
1212
from sentry.models import Option
1313
from sentry.options.store import OptionsStore
1414
from sentry.testutils import TestCase
@@ -17,9 +17,9 @@
1717
class OptionsStoreTest(TestCase):
1818
@fixture
1919
def store(self):
20-
return OptionsStore(
21-
cache=RedisCache()
22-
)
20+
c = LocMemCache('test', {})
21+
c.clear()
22+
return OptionsStore(cache=c)
2323

2424
@fixture
2525
def key(self):

0 commit comments

Comments
 (0)