def generate(self, url) -> str: redis = redis_client() step = 1 if self.random_step <= 1 else random.randint( 1, self.random_step) uid = redis.incr(self.KEY, step) return base62.encode(uid)
def generate(self, url) -> str: step = random.randint(0, self.STEP_MAX) uid = self._snowflake_client.next_id() return base62.encode((uid << self.STEP_SHIFT_BITS) | step)
def generate(self, url) -> str: data = next(self._generator) + random.randint(0, 1000) return base62.encode(data)
def generate(self, url) -> str: random_id = self._sha1(url) return base62.encode(random_id)[:6]
def generate(self, url) -> str: response = requests.get(self.snowflake_url) data = int(response.text) return base62.encode(data)