diff --git a/src/main/java/org/entur/lamassu/cache/PricingPlanCache.java b/src/main/java/org/entur/lamassu/cache/PricingPlanCache.java new file mode 100644 index 00000000..136bf2e1 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/PricingPlanCache.java @@ -0,0 +1,23 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache; + +import org.entur.lamassu.model.entities.PricingPlan; + +public interface PricingPlanCache extends EntityCache {} diff --git a/src/main/java/org/entur/lamassu/cache/SystemCache.java b/src/main/java/org/entur/lamassu/cache/SystemCache.java new file mode 100644 index 00000000..5ae964c1 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/SystemCache.java @@ -0,0 +1,23 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache; + +import org.entur.lamassu.model.entities.System; + +public interface SystemCache extends EntityCache {} diff --git a/src/main/java/org/entur/lamassu/cache/VehicleTypeCache.java b/src/main/java/org/entur/lamassu/cache/VehicleTypeCache.java new file mode 100644 index 00000000..6edfa7f6 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/VehicleTypeCache.java @@ -0,0 +1,23 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache; + +import org.entur.lamassu.model.entities.VehicleType; + +public interface VehicleTypeCache extends EntityCache {} diff --git a/src/main/java/org/entur/lamassu/cache/impl/PricingPlanCacheImpl.java b/src/main/java/org/entur/lamassu/cache/impl/PricingPlanCacheImpl.java new file mode 100644 index 00000000..3f21d5f5 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/impl/PricingPlanCacheImpl.java @@ -0,0 +1,33 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache.impl; + +import org.entur.lamassu.cache.PricingPlanCache; +import org.entur.lamassu.model.entities.PricingPlan; +import org.redisson.api.RMapCache; +import org.springframework.beans.factory.annotation.Autowired; + +public class PricingPlanCacheImpl + extends EntityCacheImpl + implements PricingPlanCache { + + public PricingPlanCacheImpl(@Autowired RMapCache cache) { + super(cache); + } +} diff --git a/src/main/java/org/entur/lamassu/cache/impl/SystemCacheImpl.java b/src/main/java/org/entur/lamassu/cache/impl/SystemCacheImpl.java new file mode 100644 index 00000000..350fe8d9 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/impl/SystemCacheImpl.java @@ -0,0 +1,33 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache.impl; + +import org.entur.lamassu.cache.SystemCache; +import org.entur.lamassu.model.entities.System; +import org.redisson.api.RMapCache; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class SystemCacheImpl extends EntityCacheImpl implements SystemCache { + + public SystemCacheImpl(@Autowired RMapCache cache) { + super(cache); + } +} diff --git a/src/main/java/org/entur/lamassu/cache/impl/VehicleTypeCacheImpl.java b/src/main/java/org/entur/lamassu/cache/impl/VehicleTypeCacheImpl.java new file mode 100644 index 00000000..63bbd304 --- /dev/null +++ b/src/main/java/org/entur/lamassu/cache/impl/VehicleTypeCacheImpl.java @@ -0,0 +1,33 @@ +/* + * + * + * * Licensed under the EUPL, Version 1.2 or – as soon they will be approved by + * * the European Commission - subsequent versions of the EUPL (the "Licence"); + * * You may not use this work except in compliance with the Licence. + * * You may obtain a copy of the Licence at: + * * + * * https://joinup.ec.europa.eu/software/page/eupl + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the Licence is distributed on an "AS IS" basis, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the Licence for the specific language governing permissions and + * * limitations under the Licence. + * + */ + +package org.entur.lamassu.cache.impl; + +import org.entur.lamassu.cache.VehicleTypeCache; +import org.entur.lamassu.model.entities.VehicleType; +import org.redisson.api.RMapCache; +import org.springframework.beans.factory.annotation.Autowired; + +public class VehicleTypeCacheImpl + extends EntityCacheImpl + implements VehicleTypeCache { + + protected VehicleTypeCacheImpl(@Autowired RMapCache cache) { + super(cache); + } +} diff --git a/src/main/java/org/entur/lamassu/config/cache/RedissonCacheConfig.java b/src/main/java/org/entur/lamassu/config/cache/RedissonCacheConfig.java index 999a38da..931834a7 100644 --- a/src/main/java/org/entur/lamassu/config/cache/RedissonCacheConfig.java +++ b/src/main/java/org/entur/lamassu/config/cache/RedissonCacheConfig.java @@ -6,8 +6,10 @@ import org.entur.lamassu.cache.VehicleSpatialIndexId; import org.entur.lamassu.config.project.LamassuProjectInfoConfiguration; import org.entur.lamassu.model.entities.GeofencingZones; +import org.entur.lamassu.model.entities.PricingPlan; import org.entur.lamassu.model.entities.Station; import org.entur.lamassu.model.entities.Vehicle; +import org.entur.lamassu.model.entities.VehicleType; import org.redisson.Redisson; import org.redisson.api.RBucket; import org.redisson.api.RGeo; @@ -30,6 +32,9 @@ public class RedissonCacheConfig { public static final String GBFS_FEED_CACHE_KEY = "gbfsFeedCache"; public static final String GBFS_V3_FEED_CACHE_KEY = "gbfsV3FeedCache"; + public static final String SYSTEM_CACHE_KEY = "systemCache"; + public static final String VEHICLE_TYPE_CACHE_KEY = "vehicleTypeCache"; + public static final String PRICING_PLAN_CACHE_KEY = "pricingPlanCache"; public static final String VEHICLE_CACHE_KEY = "vehicleCache"; public static final String STATION_CACHE_KEY = "stationCache"; public static final String GEOFENCING_ZONES_CACHE_KEY = "geofencingZonesCache"; @@ -114,6 +119,25 @@ RMapCache v3FeedCache(RedissonClient redissonClient) { ); } + @Bean + public RMapCache systemCache(RedissonClient redissonClient) { + return redissonClient.getMapCache(SYSTEM_CACHE_KEY + "_" + serializationVersion); + } + + @Bean + public RMapCache vehicleTypeCache(RedissonClient redissonClient) { + return redissonClient.getMapCache( + VEHICLE_TYPE_CACHE_KEY + "_" + serializationVersion + ); + } + + @Bean + public RMapCache pricingPlanCache(RedissonClient redissonClient) { + return redissonClient.getMapCache( + PRICING_PLAN_CACHE_KEY + "_" + serializationVersion + ); + } + @Bean public RMapCache vehicleCache(RedissonClient redissonClient) { return redissonClient.getMapCache(VEHICLE_CACHE_KEY + "_" + serializationVersion);