Coded caching with optimized shared-cache sizes