UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tuHQIXTzOs7Ed4Vvd4HVSRthhRb27tJs6WWMCpr+wdY=' 
WHERE 
  key_id = '375ca0a478d10c9663db7844c642ff3f4fef0006727c4c6c08c827831b301efb' 
  AND (
    token = 'tuHQIXTzOs7Ed4Vvd4HVSRthhRb27tJs6WWMCpr+wdY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034