getting cheto here, how about doing this in the "redis way"? where there's an atomic operation for updating a key (and automagically created if it doesn't exist). it could pass 'undefined' to the fun()