Exemple #1
0
 def test_basic_cache_operations(self):
     """
         Test basic cache operations
     """
     # clean test cache
     cache.cache_backend.clear()
     self.assertEqual(None, cache.get("test-cache"))
     cache.set("test-cache", "awesome content")
     self.assertTrue("awesome content", cache.get("test-cache"))
     cache.delete("test-cache")
     self.assertEqual(None, cache.get("test-cache"))
 def test_basic_cache_operations(self):
     """
         Test basic cache operations
     """
     # clean test cache
     cache.cache_backend.clear()
     self.assertEqual(None, cache.get('test-cache'))
     cache.set('test-cache', 'awesome content')
     self.assertTrue('awesome content', cache.get('test-cache'))
     cache.delete('test-cache')
     self.assertEqual(None, cache.get('test-cache'))
Exemple #3
0
 def test_basic_cache_operations(self):
     """
         Test basic cache operations
     """
     # clean test cache
     cache.cache_backend.clear()
     self.assertEqual(None, cache.get('test-cache'))
     cache.set('test-cache', 'awesome content')
     self.assertTrue('awesome content', cache.get('test-cache'))
     cache.delete('test-cache')
     self.assertEqual(None, cache.get('test-cache'))
def get_email_template(name):
    """
    Function that returns an email template instance, from cache or DB.
    """
    if hasattr(settings, 'POST_OFFICE_CACHE') and settings.POST_OFFICE_TEMPLATE_CACHE is False:
        return EmailTemplate.objects.get(name=name)
    else:
        email_template = cache.get(name)
        if email_template is not None:
            return email_template
        else:
            email_template = EmailTemplate.objects.get(name=name)
            cache.set(name, email_template)
            return email_template
Exemple #5
0
def get_email_template(name):
    """
    Function to get email template object that checks from cache first if caching is enabled
    """
    if hasattr(settings, 'POST_OFFICE_CACHE') and settings.POST_OFFICE_TEMPLATE_CACHE is False:
        return EmailTemplate.objects.get(name=name)
    else:
        email_template = cache.get(name)
        if email_template is not None:
            return email_template
        else:
            email_template = EmailTemplate.objects.get(name=name)
            cache.set(name, email_template)
            return email_template
def get_email_template(name):
    """
    Function that returns an email template instance, from cache or DB.
    """
    if hasattr(settings, 'POST_OFFICE_CACHE'
               ) and settings.POST_OFFICE_TEMPLATE_CACHE is False:
        return EmailTemplate.objects.get(name=name)
    else:
        email_template = cache.get(name)
        if email_template is not None:
            return email_template
        else:
            email_template = EmailTemplate.objects.get(name=name)
            cache.set(name, email_template)
            return email_template
def get_email_template(name, language=''):
    """
    Function that returns an email template instance, from cache or DB.
    """
    use_cache = getattr(settings, 'POST_OFFICE_CACHE', True)
    if use_cache:
        use_cache = getattr(settings, 'POST_OFFICE_TEMPLATE_CACHE', True)
    if not use_cache:
        return EmailTemplate.objects.get(name=name, language=language)
    else:
        composite_name = '%s:%s' % (name, language)
        email_template = cache.get(composite_name)
        if email_template is None:
            email_template = EmailTemplate.objects.get(name=name,
                                                       language=language)
            cache.set(composite_name, email_template)
        return email_template
Exemple #8
0
def get_email_template(name, language=''):
    """
    Function that returns an email template instance, from cache or DB.
    """
    use_cache = getattr(settings, 'POST_OFFICE_CACHE', True)
    if use_cache:
        use_cache = getattr(settings, 'POST_OFFICE_TEMPLATE_CACHE', True)
    if not use_cache:
        return EmailTemplate.objects.get(name=name, language=language)
    else:
        composite_name = '%s:%s' % (name, language)
        email_template = cache.get(composite_name)
        if email_template is not None:
            return email_template
        else:
            email_template = EmailTemplate.objects.get(name=name,
                                                       language=language)
            cache.set(composite_name, email_template)
            return email_template