<commit_before>import urlparse
from limits.storage import Storage
from redislite import Redis
import time

class LimitsRedisLite(Storage): # For Python Limits
    STORAGE_SCHEME = "redislite"
    def __init__(self, uri, **options):
        self.redis_instance = Redis(urlparse.urlparse(uri).netloc)

    def check(self):
        return True

    def get_expiry(self, key):
        return self.redis_instance.ttl(key)

    def incr(self, key, expiry, elastic_expiry=False):
        if not self.redis_instance.exists(key):
            self.redis_instance.set(key, 1)
            self.redis_instance.expireat(key, int(time.time() + expiry))
        else:
            oldexp = self.get_expiry(key)
            self.redis_instance.set(key, int(self.redis_instance.get(key))+1)
            self.redis_instance.expireat(key, int(time.time() + oldexp))
        return

    def get(self, key):
        return int(self.redis_instance.get(key))

    def reset(self):
        return self.redis_instance.flushdb()<commit_msg>Fix custom redislite to account for the none errors<commit_after>import urlparse
from limits.storage import Storage
from redislite import Redis
import time

class LimitsRedisLite(Storage): # For Python Limits
    STORAGE_SCHEME = "redislite"
    def __init__(self, uri, **options):
        self.redis_instance = Redis(urlparse.urlparse(uri).netloc)

    def check(self):
        return True

    def get_expiry(self, key):
        return self.redis_instance.ttl(key) or 0

    def incr(self, key, expiry, elastic_expiry=False):
        if not self.redis_instance.exists(key):
            self.redis_instance.set(key, 1, ex=expiry)
        else:
            oldexp = self.get_expiry(key)
            self.redis_instance.set(key, int(self.redis_instance.get(key))+1, ex=oldexp)
        return

    def get(self, key):
        return int(self.redis_instance.get(key))

    def reset(self):
        return self.redis_instance.flushdb()
{'fraction_non_alphanumeric': 0.10396294390118374, 'fraction_numerical': 0.0025733401955738548, 'mean_word_length': 3.0415800415800414, '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': '3212233', 'n_tokens_mistral': 660, 'n_tokens_neox': 635, 'n_words': 135}