()
| 33 | } |
| 34 | |
| 35 | func GetExposedData() gin.H { |
| 36 | if c, ok := exposedData.Load().(*exposedCache); ok && c != nil && time.Now().Before(c.expiresAt) { |
| 37 | return cloneGinH(c.data) |
| 38 | } |
| 39 | rebuildMu.Lock() |
| 40 | defer rebuildMu.Unlock() |
| 41 | if c, ok := exposedData.Load().(*exposedCache); ok && c != nil && time.Now().Before(c.expiresAt) { |
| 42 | return cloneGinH(c.data) |
| 43 | } |
| 44 | newData := gin.H{ |
| 45 | "model_ratio": GetModelRatioCopy(), |
| 46 | "completion_ratio": GetCompletionRatioCopy(), |
| 47 | "cache_ratio": GetCacheRatioCopy(), |
| 48 | "model_price": GetModelPriceCopy(), |
| 49 | } |
| 50 | exposedData.Store(&exposedCache{ |
| 51 | data: newData, |
| 52 | expiresAt: time.Now().Add(exposedDataTTL), |
| 53 | }) |
| 54 | return cloneGinH(newData) |
| 55 | } |
no test coverage detected