func New(lruCacheSize int, tileDir string, expiration time.Duration) (*SRTM, error) {
	log.Info().Caller().Int("LRU cache size", lruCacheSize).Str("tile dir", tileDir).Msg("")
	cache, err := lru.NewWithEvict(lruCacheSize, func(key interface{}, value interface{}) {
		log.Debug().Caller().Msgf("remove tile '%s' from cache", key.(string))
		tile, ok := value.(*Tile)
		if !ok {
			log.Error().Caller().Msgf("cache value for key '%s' is not a tile (%+v)", key, value)
			return
		}
		if tile.f != nil {
			if err := tile.f.Close(); err != nil {
				log.Error().Caller().Err(err).Msg("")
			}
		}
		runtime.GC()
	})
	if err != nil {
		log.Error().Caller().Err(err).Msg("")
		return nil, err
	}
	srtm := &SRTM{
		cache:         cache,
		mtx:           sync.Mutex{},
		tileDirectory: tileDir,
		done:          make(chan struct{}),
		bads:          make([]string, 0),
	}
	if expiration > 0 {
		go srtm.sanityCleanLoop(expiration)
	}
	return srtm, nil
}
// New make initialization of cache
New make initialization of cache
// New make initialization of cache
func New(lruCacheSize int, tileDir string, expiration time.Duration) (*SRTM, error) {
	log.Info().Caller().Int("LRU cache size", lruCacheSize).Str("tile dir", tileDir).Msg("")
	cache, err := lru.NewWithEvict(lruCacheSize, func(key interface{}, value interface{}) {
		log.Debug().Caller().Msgf("remove tile '%s' from cache", key.(string))
		tile, ok := value.(*Tile)
		if !ok {
			log.Error().Caller().Msgf("cache value for key '%s' is not a tile (%+v)", key, value)
			return
		}
		if tile.f != nil {
			if err := tile.f.Close(); err != nil {
				log.Error().Caller().Err(err).Msg("")
			}
		}
		runtime.GC()
	})
	if err != nil {
		log.Error().Caller().Err(err).Msg("")
		return nil, err
	}
	srtm := &SRTM{
		cache:         cache,
		mtx:           sync.Mutex{},
		tileDirectory: tileDir,
		done:          make(chan struct{}),
		bads:          make([]string, 0),
	}
	if expiration > 0 {
		go srtm.sanityCleanLoop(expiration)
	}
	return srtm, nil
}
func New ( lruCacheSize int , tileDir string , expiration time . Duration ) ( * SRTM , error ) { log . Info ( ) . Caller ( ) . Int ( " " , lruCacheSize ) . Str ( " " , tileDir ) . Msg ( " " ) cache , err := lru . NewWithEvict ( lruCacheSize , func ( key interface { } , value interface { } ) { log . Debug ( ) . Caller ( ) . Msgf ( " " , key . ( string ) ) tile , ok := value . ( * Tile ) if ! ok { log . Error ( ) . Caller ( ) . Msgf ( " " , key , value ) return } if tile . f != nil { if err := tile . f . Close ( ) ; err != nil { log . Error ( ) . Caller ( ) . Err ( err ) . Msg ( " " ) } } runtime . GC ( ) } ) if err != nil { log . Error ( ) . Caller ( ) . Err ( err ) . Msg ( " " ) return nil , err } srtm := & SRTM { cache : cache , mtx : sync . Mutex { } , tileDirectory : tileDir , done : make ( chan struct { } ) , bads : make ( [ ] string , 0 ) , } if expiration > 0 { go srtm . sanityCleanLoop ( expiration ) } return srtm , nil }
New make initialization of cache
New make initialization of cache