Can anyone suggest me a caching library for ktor s...
# server
m
Can anyone suggest me a caching library for ktor server?
j
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
@Jilles van Gurp thank you verymuch i will try it
Does caffeine cache manager work good in kotlin?
j
Never used it but I don't see any reason why it wouldn't
m
Before i tried ehcache library but it throws an error serializer not found for custom object since i am using kotlinx serializer
a
ehcache supports custom serializers
m
Dont know how to implement custom serializer for kotlin data class. If any tuto link please give me
m
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
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
I've used caffeine with Kotlin with no problems. It was simple and easy to configure.
a
On my way.
s
581 Views