UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'cAa6Ww6POwzQ7aQFaShQWttVaX41LHo6fnKQSx+7qxM='
WHERE
key_id = '51b2df1235e296de9ddcfdd774a90c44d605d4594a465f8648e54978be1819d3'
AND (
token = 'cAa6Ww6POwzQ7aQFaShQWttVaX41LHo6fnKQSx+7qxM='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)