UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '6bDo9Rl8bjecbOtN9AODhTkgSY9kIj8pIb9LGBhHe3M='
WHERE
key_id = '4a38d770be6c3de6ac17b0a4a113fe4a60be357005739072e118d15962294e4a'
AND (
token = '6bDo9Rl8bjecbOtN9AODhTkgSY9kIj8pIb9LGBhHe3M='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)