How does current version of traccar cache works?

Victor Butler2 days ago

Hi,

I have been checking the code but I am not entirely sure I understand how the cache currently works. Can you confirm on the below please?

  1. On server start, the cache is being build in the java heap
  2. The way to build the cache on server start is by accessing storage and getting the objects from there
  3. If an object is updated, the cache is also being updated (This I can see in the code).
  4. On server restart the cache is "deleted" and is being rebuilt once again after server starts.

May I ask for a favor, can you point out to the file/code used to store the objects in the cache after restart?

Thank you!

Anton Tananaev2 days ago
  1. No.
  2. Not sure I understand this point.
  3. Yes, if you use the API.
  4. Yes, deleted.
Victor Butler2 days ago

So points 1 and 2 are the essence of the question.

So I guess, what I am asking is how are the objects fetched once the server starts?

If we get this code as example:

for (Maintenance maintenance : cacheManager.getDeviceObjects(position.getDeviceId(), Maintenance.class))

When and how are the maintenances fetched so that they are available here?

what I am asking is how are the objects fetched once the server starts?

Cache is not populated on the server start. Cache is only populated when a device connects to the server.

Victor Butlera day ago

That's a better approach.

So the device connects and we get the objects connected to this device like maintenances or notifications based on what's available in the tc_device_maintenance or tc_device_notifications tables?
If so, how do you get the maintenance objects from storage?