Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
28
pkg/cache/car_dtcs.go
vendored
Normal file
28
pkg/cache/car_dtcs.go
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fiskerinc.com/modules/common"
|
||||
)
|
||||
|
||||
type CarDTCsCacheInterface interface {
|
||||
Exists(dtc common.DTC_ECU) bool
|
||||
Set(dtc common.DTC_ECU)
|
||||
}
|
||||
|
||||
type CarDTCsCache struct {
|
||||
ringMap *RingMap
|
||||
}
|
||||
|
||||
func NewCarDTCsCache(capacity int) CarDTCsCacheInterface {
|
||||
return &CarDTCsCache{
|
||||
ringMap: NewRingMap(capacity),
|
||||
}
|
||||
}
|
||||
|
||||
func (carDtcCache *CarDTCsCache) Exists(dtc common.DTC_ECU) bool {
|
||||
return carDtcCache.ringMap.Exists(dtc.CacheKey(), dtc.StatusByte)
|
||||
}
|
||||
|
||||
func (carDtcCache *CarDTCsCache) Set(dtc common.DTC_ECU) {
|
||||
carDtcCache.ringMap.Put(dtc.CacheKey(), dtc.StatusByte)
|
||||
}
|
||||
Reference in New Issue
Block a user