UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '4t72TZIao7H5FCtinxfTi0k831LvirpmPJDEoWxVFLQ=' 
WHERE 
  key_id = '5aed3c36a3c495565a14c0b65d6648d436436e6a8e6d736b1d89ced373817699' 
  AND (
    token = '4t72TZIao7H5FCtinxfTi0k831LvirpmPJDEoWxVFLQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036