mirror of
https://github.com/samuelncui/yatm.git
synced 2026-01-05 13:05:42 +00:00
feat: job list
This commit is contained in:
15
tools/cache.go
Normal file
15
tools/cache.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package tools
|
||||
|
||||
func Cache[i comparable, o any](f func(in i) o) func(in i) o {
|
||||
cache := make(map[i]o, 0)
|
||||
return func(in i) o {
|
||||
cached, has := cache[in]
|
||||
if has {
|
||||
return cached
|
||||
}
|
||||
|
||||
out := f(in)
|
||||
cache[in] = out
|
||||
return out
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user