Traccar cache for 24 hours?

Nikolay 2 years ago

Hello everyone,

I have a traccar 5.x instance with about 20 devices.
I have to make averages of one parameter (temperature) for 1 hour and for 24 hours .
For this purpose i am using api/positions/<id><from><to>.
The question is if there is a possibility not to make queries to the database, but to use the traccar cache? I.e. set the cache to hold positions for 24 hours. Or about 25k positions?
Also for api/positions which column in tc_positions is suitable for indexing in PostgreSql

Thanks in advance

Anton Tananaev2 years ago

You can change the code and add any caching you want. There's obviously no such specific config option.

As for database index, it should already be there.

Nikolay 2 years ago

Hi again,

Anton thanks for the reply.
I'm not familiar with static languages, but I looked at the source code and found CacheManager in CacheManager.java Here and ServletContextHandler in WebServer.java Here

Unfortunately, I didn't understand if you mean to implement a new Cache model or pass a different value to an already done implementation.

I would appreciate if you could give me a hint.

Regards,
Nikolay

Anton Tananaev2 years ago

You would probably need a completely different cache.

Nikolay 2 years ago

Hi Anton,

thanks a lot for the information. I was wondering for quite some time how exactly to modify the existing solution :)

I saw that there is an option for horizontal scaling, doesn't that mean that the cache has to be persisted, which I think will make it harder to configure the positions.select.query entry key in default.config.
Does this option exist at this time?

Anton Tananaev2 years ago

It doesn't exist anymore.