def save_to_cache(dxobject):
    '''
    :param dxobject: a dxpy object handler for an object to save to the cache
    :raises: :exc:`~dxpy.exceptions.DXError` if this is called with dxpy.JOB_ID not set, or if "DX_PROJECT_CACHE_ID" is not found in the environment variables

    Clones the given object to the project cache.

    Example::

        @dxpy.entry_point('main')
        def main(*args, **kwargs):
            x = load_from_cache(name="Indexed genome", classname='file')
            if x is None:
                x = compute_result(*args)
                save_to_cache(x)
    '''

    if dxpy.JOB_ID is None:
        raise DXError('Not called by a job')
    if 'DX_PROJECT_CACHE_ID' not in os.environ:
        raise DXError('Project cache ID could not be found in the environment variable DX_PROJECT_CACHE_ID')

    dxobject.clone(os.environ.get('DX_PROJECT_CACHE_ID'))
dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/bindings/dxapp_container_functions.py/save_to_cache/original