I am looking at a solution to providing a guaranteed contiguous sequence of numbers. This cannot be achieved via autonumber fields as numbers in the series are consumed by failed validations etc. - not to mention the problem with tests burning the sequence as well (though this can be mitigated by asking SFDC to activate a beta feature to enable rollbacks to roll back the sequence, at the expense of some performance).
One idea is to use a custom setting. Custom settings values are held in an application cache to minimise DB access. If a custom setting is updated via DML, is the value replicated into all instances of the cache immediately?
My concern is that where there is multiple concurrent access to this number, at the point of update the cache could be stale for at least some requests.
Has anyone solved this problem satisfactorily?