Completed
Push — master ( e6b198...e30f90 )
by Messense
11:09 queued 10:06
created

MemoryStorage.get()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
cc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
1
# -*- coding: utf-8 -*-
2 10
from __future__ import absolute_import, unicode_literals
3 10
from wechatpy.session import SessionStorage
4
5
6 10
class MemoryStorage(SessionStorage):
7
8 10
    def __init__(self):
9 10
        self._data = {}
10
11 10
    def get(self, key, default=None):
12 10
        return self._data.get(key, default)
13
14 10
    def set(self, key, value, ttl=None):
15 10
        if value is None:
16 10
            return
17 10
        self._data[key] = value
18
19 10
    def delete(self, key):
20
        self._data.pop(key, None)
21