pyaltt2/db.py
def put(self, key=None, value=None, expires=None, override=True):
        """
        Put object to key-value storage

        If no key specified, random 64-char key is generated

        Args:
            key: string key (1-255 chars)
            value: value to put
            expires: expiration either in seconds or datetime.timedelta
            override: replace existing object
        Returns:
            object key
        """
        from msgpack import dumps
        if key is None:
            key = gen_random_str(length=64)
        elif override:
            try:
                self.delete(key)
            except LookupError:
                pass
        value = dumps(value)
        if expires is None:
            self.db.query('kv.put',
                          qargs=[self.table_name],
                          id=key,
                          content=value)
        else:
            d_expires = datetime.datetime.now() + datetime.timedelta(
                seconds=expires) if isinstance(
                    expires, int) else datetime.datetime.now() + expires
            self.db.query('kv.put.expires',
                          qargs=[self.table_name],
                          id=key,
                          content=value,
                          d_expires=d_expires)
        return key

        Put object to key-value storage

        If no key specified, random 64-char key is generated

        Args:
            key: string key (1-255 chars)
            value: value to put
            expires: expiration either in seconds or datetime.timedelta
            override: replace existing object
        Returns:
            object key
        
Put object to key-value storage
If no key specified, random 64-char key is generated
Put object to key - value storage If no key specified random 64 - char key is generated
def put(self, key=None, value=None, expires=None, override=True):
        from msgpack import dumps
        if key is None:
            key = gen_random_str(length=64)
        elif override:
            try:
                self.delete(key)
            except LookupError:
                pass
        value = dumps(value)
        if expires is None:
            self.db.query('kv.put',
                          qargs=[self.table_name],
                          id=key,
                          content=value)
        else:
            d_expires = datetime.datetime.now() + datetime.timedelta(
                seconds=expires) if isinstance(
                    expires, int) else datetime.datetime.now() + expires
            self.db.query('kv.put.expires',
                          qargs=[self.table_name],
                          id=key,
                          content=value,
                          d_expires=d_expires)
        return key
def put ( self , key = None , value = None , expires = None , override = True ) : from msgpack import dumps if key is None : key = gen_random_str ( length = 64 ) elif override : try : self . delete ( key ) except LookupError : pass value = dumps ( value ) if expires is None : self . db . query ( 'kv.put' , qargs = [ self . table_name ] , id = key , content = value ) else : d_expires = datetime . datetime . now ( ) + datetime . timedelta ( seconds = expires ) if isinstance ( expires , int ) else datetime . datetime . now ( ) + expires self . db . query ( 'kv.put.expires' , qargs = [ self . table_name ] , id = key , content = value , d_expires = d_expires ) return key
Put object to key-value storage
If no key specified, random 64-char key is generated
Put object to key - value storage If no key specified random 64 - char key is generated
"""
        Put object to key-value storage

        If no key specified, random 64-char key is generated

        Args:
            key: string key (1-255 chars)
            value: value to put
            expires: expiration either in seconds or datetime.timedelta
            override: replace existing object
        Returns:
            object key
        """
None
self
key
string key (1-255 chars)
string key ( 1 - 255 chars )
value
value to put
value to put
expires
expiration either in seconds or datetime.timedelta
expiration either in seconds or datetime . timedelta
override
replace existing object
replace existing object