from typing import Union
from pathlib import Path
from typing import Optional


def get_cache(cache_dir: Union[Path, str], tile: str) -> Optional[bytes]:
    """Retrieve data from the cache

    :param cache_dir: Cache directory
    :param tile: Tile to attempt to retrieve
    :return: Tile from cache or None if not in cache
    """
    # Check if tile exists
    tile_path = Path(cache_dir) / tile
    if tile_path.exists():
        return tile_path.read_bytes()