repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
SharedLRUCache.ts
diff --git
a/src/charging-station/SharedLRUCache.ts
b/src/charging-station/SharedLRUCache.ts
index e235c51d1f930a764c1e2ef8198b792711254b31..bb1c0c07e3749e99b6ee76a4d8e3486696f6eac4 100644
(file)
--- a/
src/charging-station/SharedLRUCache.ts
+++ b/
src/charging-station/SharedLRUCache.ts
@@
-1,22
+1,25
@@
-import LRUCache from 'mnemonist/lru-map-with-delete';
+import LRUCache from 'mnemonist/lru-map-with-delete
.js
';
-import
type { ChargingStationConfiguration } from '../types/ChargingStationConfiguration
';
-import type { ChargingStation
Template } from '../types/ChargingStationTemplate
';
-import
Utils from '../utils/U
tils';
+import
{ Bootstrap } from './internal
';
+import type { ChargingStation
Configuration, ChargingStationTemplate } from '../types
';
+import
{ Utils } from '../u
tils';
enum CacheType {
enum CacheType {
-
CHARGING_STATION_TEMPLATE
= 'chargingStationTemplate',
-
CHARGING_STATION_CONFIGURATION
= 'chargingStationConfiguration',
+
chargingStationTemplate
= 'chargingStationTemplate',
+
chargingStationConfiguration
= 'chargingStationConfiguration',
}
}
-type Cache
abl
eType = ChargingStationTemplate | ChargingStationConfiguration;
+type Cache
Valu
eType = ChargingStationTemplate | ChargingStationConfiguration;
-export
default
class SharedLRUCache {
+export class SharedLRUCache {
private static instance: SharedLRUCache | null = null;
private static instance: SharedLRUCache | null = null;
- private readonly lruCache: LRUCache<string, Cache
abl
eType>;
+ private readonly lruCache: LRUCache<string, Cache
Valu
eType>;
private constructor() {
private constructor() {
- this.lruCache = new LRUCache<string, CacheableType>(1000);
+ this.lruCache = new LRUCache<string, CacheValueType>(
+ Bootstrap.getInstance().numberOfChargingStationTemplates +
+ Bootstrap.getInstance().numberOfChargingStations
+ );
}
public static getInstance(): SharedLRUCache {
}
public static getInstance(): SharedLRUCache {
@@
-79,22
+82,22
@@
export default class SharedLRUCache {
}
private getChargingStationConfigurationKey(hash: string): string {
}
private getChargingStationConfigurationKey(hash: string): string {
- return `${CacheType.
CHARGING_STATION_CONFIGURATION
}${hash}`;
+ return `${CacheType.
chargingStationConfiguration
}${hash}`;
}
private getChargingStationTemplateKey(hash: string): string {
}
private getChargingStationTemplateKey(hash: string): string {
- return `${CacheType.
CHARGING_STATION_TEMPLATE
}${hash}`;
+ return `${CacheType.
chargingStationTemplate
}${hash}`;
}
private has(key: string): boolean {
return this.lruCache.has(key);
}
}
private has(key: string): boolean {
return this.lruCache.has(key);
}
- private get(key: string): Cache
abl
eType | undefined {
+ private get(key: string): Cache
Valu
eType | undefined {
return this.lruCache.get(key);
}
return this.lruCache.get(key);
}
- private set(key: string, value: Cache
abl
eType): void {
+ private set(key: string, value: Cache
Valu
eType): void {
this.lruCache.set(key, value);
}
this.lruCache.set(key, value);
}
@@
-109,9
+112,9
@@
export default class SharedLRUCache {
Utils.isNullOrUndefined(chargingStationConfiguration?.configurationKey) === false &&
Utils.isNullOrUndefined(chargingStationConfiguration?.stationInfo) === false &&
Utils.isNullOrUndefined(chargingStationConfiguration?.configurationHash) === false &&
Utils.isNullOrUndefined(chargingStationConfiguration?.configurationKey) === false &&
Utils.isNullOrUndefined(chargingStationConfiguration?.stationInfo) === false &&
Utils.isNullOrUndefined(chargingStationConfiguration?.configurationHash) === false &&
- Utils.is
EmptyArray(chargingStationConfiguration?.configurationKey) === fals
e &&
+ Utils.is
NotEmptyArray(chargingStationConfiguration?.configurationKey) === tru
e &&
Utils.isEmptyObject(chargingStationConfiguration?.stationInfo) === false &&
Utils.isEmptyObject(chargingStationConfiguration?.stationInfo) === false &&
- Utils.is
EmptyString(chargingStationConfiguration?.configurationHash) === fals
e
+ Utils.is
NotEmptyString(chargingStationConfiguration?.configurationHash) === tru
e
);
}
}
);
}
}