Created
January 27, 2023 10:04
-
-
Save arriqaaq/58ad348dade7f0054d05911b1a6233bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image" | |
"sync" | |
) | |
var imageCache = sync.Map{} | |
func getImage(path string) image.Image { | |
if img, ok := imageCache.Load(path); ok { | |
return img.(image.Image) | |
} | |
img := loadImage(path) | |
imageCache.Store(path, img) | |
return img | |
} | |
func loadImage(path string) image.Image { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment