Created
April 30, 2019 08:04
-
-
Save bwangelme/4002260ea023736eb7e51bb0a53a23e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import json | |
import datetime | |
db = redis.Client() | |
class ID(object): | |
key = "ID/unique" | |
def _props_setter(self, props): | |
db.set(self.key, json.encode(props)) | |
def _props_getter(self): | |
data = db.get(self.key) | |
return json.decode(data) | |
props = property(_props_getter, _props_setter) | |
def set_id_time(self): | |
self.props['time'] = datetime.datetime.now().strftime('%Y/%m/%d') | |
self.update() | |
def update(self): | |
self.props = self.props | |
def update_id_time(): | |
id = ID() | |
id.set_id_time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment