There are a large number of variables that go into how long a cassette will last. This makes it difficult to give a specific number of hours or miles that a cassette will last before needing replacement. Some of those variables include riding conditions, personal gearing preferences, rider weight, rider power, front chainring size, drivetrain maintenance.
For example, a heavier rider who regularly rides in muddy conditions and with long sustained climbs that favor one or two of the alloy cogs will wear a cassette much quicker than one riding in mild conditions with undulating terrain that spreads out chain position and wear across more of the cassette.
Two of the best things you can do to maximize the life of your cassette is to regularly check your chain for wear (and replace when necessary) and keep your drivetrain clean and lubed.
For riders in places with flat terrain riding frequently in the smaller cogs, increasing the size of your chainring will result in more frequently being in the middle section of the cassette which can improve longevity.
For riders in places with big climbs frequently in larger alloy cogs, reducing the size of your chainring can result in more time being spent on the steel portion of the cassette which can improve longevity.