Skip to content

Commit

Permalink
Add new caches for system, vehicle type and pricing plan to prepare f…
Browse files Browse the repository at this point in the history
…or denormalization
  • Loading branch information
testower committed Dec 19, 2024
1 parent e22e1fe commit f481798
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/org/entur/lamassu/cache/PricingPlanCache.java
Original file line number Diff line number Diff line change
@@ -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<PricingPlan> {}
23 changes: 23 additions & 0 deletions src/main/java/org/entur/lamassu/cache/SystemCache.java
Original file line number Diff line number Diff line change
@@ -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<System> {}
23 changes: 23 additions & 0 deletions src/main/java/org/entur/lamassu/cache/VehicleTypeCache.java
Original file line number Diff line number Diff line change
@@ -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<VehicleType> {}
Original file line number Diff line number Diff line change
@@ -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<PricingPlan>
implements PricingPlanCache {

public PricingPlanCacheImpl(@Autowired RMapCache<String, PricingPlan> cache) {
super(cache);
}
}
33 changes: 33 additions & 0 deletions src/main/java/org/entur/lamassu/cache/impl/SystemCacheImpl.java
Original file line number Diff line number Diff line change
@@ -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<System> implements SystemCache {

public SystemCacheImpl(@Autowired RMapCache<String, System> cache) {
super(cache);
}
}
Original file line number Diff line number Diff line change
@@ -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<VehicleType>
implements VehicleTypeCache {

protected VehicleTypeCacheImpl(@Autowired RMapCache<String, VehicleType> cache) {
super(cache);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -114,6 +119,25 @@ RMapCache<String, Object> v3FeedCache(RedissonClient redissonClient) {
);
}

@Bean
public RMapCache<String, System> systemCache(RedissonClient redissonClient) {
return redissonClient.getMapCache(SYSTEM_CACHE_KEY + "_" + serializationVersion);
}

@Bean
public RMapCache<String, VehicleType> vehicleTypeCache(RedissonClient redissonClient) {
return redissonClient.getMapCache(
VEHICLE_TYPE_CACHE_KEY + "_" + serializationVersion
);
}

@Bean
public RMapCache<String, PricingPlan> pricingPlanCache(RedissonClient redissonClient) {
return redissonClient.getMapCache(
PRICING_PLAN_CACHE_KEY + "_" + serializationVersion
);
}

@Bean
public RMapCache<String, Vehicle> vehicleCache(RedissonClient redissonClient) {
return redissonClient.getMapCache(VEHICLE_CACHE_KEY + "_" + serializationVersion);
Expand Down

0 comments on commit f481798

Please sign in to comment.