UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'DiHDDkZcPYBceW9F2vMDpsmmGvOEoHKmbGpny9REhg4='
WHERE
key_id = 'babc007b2628462334fb4a707fc27c7acd74496f7b8c170cd2080c7e5fabe124'
AND (
token = 'DiHDDkZcPYBceW9F2vMDpsmmGvOEoHKmbGpny9REhg4='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)