Aquerr / EagleFactions

A simple yet powerful factions plugin for SpongeForge.
MIT License
32 stars 13 forks source link

Cache to improve performance of "getFactionByChunk" method #126

Closed NoTimeForHero closed 4 years ago

NoTimeForHero commented 4 years ago

"getFactionByChunk" one of the most called methods by many listeners. But it iterating every time through every faction claims.

So I cached it with thread safe Guava cache. I limit the cache 30 seconds for safety, if someone will forget to invalidate cache after updating claims.

Aquerr commented 4 years ago

Looks good. Have you tested it in game by yourself?

NoTimeForHero commented 4 years ago

Yes, I tested it, but only locally (have no server with players for normal tests)