refactor: rename an id tags cache method
[e-mobility-charging-stations-simulator.git] / src / charging-station / IdTagsCache.ts
index 48ecb552a90b7c23f0f474952cdb33b87cd49dbb..8d4027839851151374d23c795d04520d5fa9ee0f 100644 (file)
@@ -58,7 +58,7 @@ export class IdTagsCache {
 
   private getRandomIdTag(hashId: string, file: string): string {
     const idTags = this.getIdTags(file);
-    const addressableKey = file + hashId;
+    const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId);
     this.idTagsCachesAddressableIndexes.set(
       addressableKey,
       Math.floor(Utils.secureRandom() * idTags.length)
@@ -68,7 +68,7 @@ export class IdTagsCache {
 
   private getRoundRobinIdTag(hashId: string, file: string): string {
     const idTags = this.getIdTags(file);
-    const addressableKey = file + hashId;
+    const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId);
     const idTagIndex = this.idTagsCachesAddressableIndexes.get(addressableKey) ?? 0;
     const idTag = idTags[idTagIndex];
     this.idTagsCachesAddressableIndexes.set(
@@ -82,7 +82,7 @@ export class IdTagsCache {
     const file = ChargingStationUtils.getIdTagsFile(chargingStation.stationInfo);
     const idTags = this.getIdTags(file);
     const hashId = chargingStation.stationInfo.hashId;
-    const addressableKey = file + hashId;
+    const addressableKey = this.getIdTagsCacheIndexesAddressableKey(file, hashId);
     this.idTagsCachesAddressableIndexes.set(
       addressableKey,
       (chargingStation.index - 1 + (connectorId - 1)) % idTags.length
@@ -144,6 +144,10 @@ export class IdTagsCache {
     }
   }
 
+  private getIdTagsCacheIndexesAddressableKey(prefix: string, uid: string): string {
+    return `${prefix}${uid}`;
+  }
+
   private getIdTagsFromFile(file: string): string[] {
     let idTags: string[] = [];
     if (file) {