<commit_before>import errno
import os

from .base import *  # noqa
from .south_africa_base import *  # noqa

HAYSTACK_CONNECTIONS['default']['EXCLUDED_INDEXES'] = [
    'pombola.search.search_indexes.PlaceIndex',
    'speeches.search_indexes.SpeechIndex',
]

HAYSTACK_CONNECTIONS['default']['ENGINE'] = 'pombola.south_africa.search.ZAElasticSearchEngine'


INSTALLED_APPS = insert_after(INSTALLED_APPS,
                              'markitup',
                              'pombola.' + COUNTRY_APP)

INSTALLED_APPS += OPTIONAL_APPS

# This is needed by the speeches application
MIDDLEWARE_CLASSES += ( 'pombola.middleware.FakeInstanceMiddleware', )

ENABLED_FEATURES = make_enabled_features(INSTALLED_APPS, ALL_OPTIONAL_APPS)

PIPELINE_CSS.update(COUNTRY_CSS)
PIPELINE_JS.update(COUNTRY_JS)

EXCLUDE_FROM_SEARCH = ('places', 'info_pages');

PMG_API_CACHE_PATH = os.path.join(root_dir, 'pmg_api_cache')

try:
    os.makedirs(PMG_API_CACHE_PATH)
except OSError as exception:
    if exception.errno != errno.EEXIST:
        raise

CACHES['pmg_api'] = {
    'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': PMG_API_CACHE_PATH,
    'OPTIONS': {
        'MAX_ENTRIES': 10000,
        },
    'TIMEOUT': 60*60*24,
    }<commit_msg>Use an in-memory cache for the PMG API on Heroku<commit_after>import errno
import os

from .base import *  # noqa
from .south_africa_base import *  # noqa

HAYSTACK_CONNECTIONS['default']['EXCLUDED_INDEXES'] = [
    'pombola.search.search_indexes.PlaceIndex',
    'speeches.search_indexes.SpeechIndex',
]

HAYSTACK_CONNECTIONS['default']['ENGINE'] = 'pombola.south_africa.search.ZAElasticSearchEngine'


INSTALLED_APPS = insert_after(INSTALLED_APPS,
                              'markitup',
                              'pombola.' + COUNTRY_APP)

INSTALLED_APPS += OPTIONAL_APPS

# This is needed by the speeches application
MIDDLEWARE_CLASSES += ( 'pombola.middleware.FakeInstanceMiddleware', )

ENABLED_FEATURES = make_enabled_features(INSTALLED_APPS, ALL_OPTIONAL_APPS)

PIPELINE_CSS.update(COUNTRY_CSS)
PIPELINE_JS.update(COUNTRY_JS)

EXCLUDE_FROM_SEARCH = ('places', 'info_pages');

PMG_API_CACHE_PATH = os.path.join(root_dir, 'pmg_api_cache')

if 'ON_HEROKU' in os.environ:
    CACHES['pmg_api'] = {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'pmg-api-in-memory-cache',
    }
else:
    try:
        os.makedirs(PMG_API_CACHE_PATH)
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise
    CACHES['pmg_api'] = {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': PMG_API_CACHE_PATH,
        'OPTIONS': {
            'MAX_ENTRIES': 10000,
            },
        'TIMEOUT': 60*60*24,
    }
{'fraction_non_alphanumeric': 0.11506652283351312, 'fraction_numerical': 0.007910823444804028, 'mean_word_length': 3.64440734557596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2992642', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1009, 'n_words': 147}