https://kotlinlang.org logo
#server
Title
# server
m

Mohamed Jabarullah

07/07/2022, 7:00 AM
Can anyone suggest me a caching library for ktor server?
j

Jilles van Gurp

07/07/2022, 12:25 PM
in process or do you want to use something like redis? If so, just use their Java client. If you want in process caching, you can use something like guava which has a cache, or just roll your own thing using a Map.
m

Mohamed Jabarullah

07/07/2022, 12:30 PM
@Jilles van Gurp thank you verymuch i will try it
Does caffeine cache manager work good in kotlin?
j

Jilles van Gurp

07/07/2022, 12:32 PM
Never used it but I don't see any reason why it wouldn't
m

Mohamed Jabarullah

07/07/2022, 12:34 PM
Before i tried ehcache library but it throws an error serializer not found for custom object since i am using kotlinx serializer
a

Alex Nordlund

07/07/2022, 12:51 PM
ehcache supports custom serializers
m

Mohamed Jabarullah

07/07/2022, 1:07 PM
Dont know how to implement custom serializer for kotlin data class. If any tuto link please give me
m

Matteo Mirk

07/08/2022, 8:17 AM
or just roll your own thing using a Map.
no please don’t do that ever ☠️, it’s like rolling your own cryptographic functions. Maps are not caches, even if on the surface they may look similar. The moment you implement your own “cache” with an (unbounded, policy-less) Map, you get a ticket for primetime troubles in production. Please please please, use an existing, tested and robust library for that.
c

corneil

07/08/2022, 8:16 PM
I've used Hazelcast in Spring but it's plain Java API is simple to use and it can be embedded or configured to connect to other instances including a standalone server. Hazelcast has a few nice features beyond caching the makes it a powerful addition to most systems.
p

Pat Kujawa

07/10/2022, 1:30 PM
I've used caffeine with Kotlin with no problems. It was simple and easy to configure.
a

Alex Nordlund

07/10/2022, 6:10 PM
On my way.
s

Scogun

12/29/2023, 2:38 PM
478 Views