我们从Python开源项目中,提取了以下26个代码示例,用于说明如何使用time.microseconds()。
def time(self): """ Returns the server time as a 2-item tuple of ints: (seconds since epoch, microseconds into this second). """ return self.execute_command('TIME')
def pexpire(self, name, time): """ Set an expire flag on key ``name`` for ``time`` milliseconds. ``time`` can be represented by an integer or a Python timedelta object. """ if isinstance(time, datetime.timedelta): ms = int(time.microseconds / 1000) time = (time.seconds + time.days * 24 * 3600) * 1000 + ms return self.execute_command('PEXPIRE', name, time)
def psetex(self, name, time_ms, value): """ Set the value of key ``name`` to ``value`` that expires in ``time_ms`` milliseconds. ``time_ms`` can be represented by an integer or a Python timedelta object """ if isinstance(time_ms, datetime.timedelta): ms = int(time_ms.microseconds / 1000) time_ms = (time_ms.seconds + time_ms.days * 24 * 3600) * 1000 + ms return self.execute_command('PSETEX', name, time_ms, value)
def set(self, name, value, ex=None, px=None, nx=False, xx=False): """ Set the value at key ``name`` to ``value`` ``ex`` sets an expire flag on key ``name`` for ``ex`` seconds. ``px`` sets an expire flag on key ``name`` for ``px`` milliseconds. ``nx`` if set to True, set the value at key ``name`` to ``value`` if it does not already exist. ``xx`` if set to True, set the value at key ``name`` to ``value`` if it already exists. """ pieces = [name, value] if ex: pieces.append('EX') if isinstance(ex, datetime.timedelta): ex = ex.seconds + ex.days * 24 * 3600 pieces.append(ex) if px: pieces.append('PX') if isinstance(px, datetime.timedelta): ms = int(px.microseconds / 1000) px = (px.seconds + px.days * 24 * 3600) * 1000 + ms pieces.append(px) if nx: pieces.append('NX') if xx: pieces.append('XX') return self.execute_command('SET', *pieces)