from functools import wraps
try:  # Python 2.*
    from django.utils.encoding import force_unicode
except ImportError:  # Python 3.*
    from django.utils.encoding import force_text
    force_unicode = force_text
from redis_sessions import settings


def redis_key(key):
    if not settings.SESSION_REDIS_PREFIX:
        return key
    return '%s:%s' % (
        settings.SESSION_REDIS_PREFIX,
        key
    )


def prefix(fn):
    @wraps(fn)
    def wrapped(*args, **kwargs):
        args = list(args)
        args[0] = redis_key(args[0])
        return fn(*args, **kwargs)
    return wrapped


def keys_pattern():
    if settings.SESSION_REDIS_PREFIX:
        pattern = '%s:*' % (
            settings.SESSION_REDIS_PREFIX,
        )
    else:
        pattern = '*'
    return pattern

@@ -248,25 +248,26 @@
 s%0A%0A%0Adef 
-redis_key
+add_prefix
 (key):%0A 
@@ -408,16 +408,189 @@
     )%0A%0A%0A
+def remove_prefix(key):%0A    if settings.SESSION_REDIS_PREFIX:%0A        key = key.replace(%0A            '%25s:' %25 settings.SESSION_REDIS_PREFIX, '', 1%0A        )%0A    return key%0A%0A%0A
 def pref
@@ -694,17 +694,18 @@
 %5D = 
-redis_key
+add_prefix
 (arg
@@ -768,197 +768,4 @@
 ped%0A
-%0A%0Adef keys_pattern():%0A    if settings.SESSION_REDIS_PREFIX:%0A        pattern = '%25s:*' %25 (%0A            settings.SESSION_REDIS_PREFIX,%0A        )%0A    else:%0A        pattern = '*'%0A    return pattern%0A

Remove useless stuff