loader/cache.go
func (c *FileCache) Set(key string, entity *CacheEntity) error {
	path := c.GetCachePath(key)
	if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil {
		return errors.Wrap(err, "failed to create directory for cache file")
	}

	// Need to avoid race condition
	file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
	if err != nil {
		return errors.Wrap(err, "failed to open/create a cache file")
	}
	defer file.Close()

	f := bufio.NewWriter(file)
	defer f.Flush()
	enc := gob.NewEncoder(f)
	if err = enc.Encode(entity); err != nil {
		return errors.Wrap(err, "failed to encode Entity via gob")
	}

	return nil
}
func (c *FileCache) Set(key string, entity *CacheEntity) error {
	path := c.GetCachePath(key)
	if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil {
		return errors.Wrap(err, "failed to create directory for cache file")
	}

	// Need to avoid race condition
	file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0666)
	if err != nil {
		return errors.Wrap(err, "failed to open/create a cache file")
	}
	defer file.Close()

	f := bufio.NewWriter(file)
	defer f.Flush()
	enc := gob.NewEncoder(f)
	if err = enc.Encode(entity); err != nil {
		return errors.Wrap(err, "failed to encode Entity via gob")
	}

	return nil
}
// Set creates a new cache file to store the ByteCode.