Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2223

How to customize SessionRepository in Spring Boot Redis

$
0
0

SafeDeserializationRepository is a class that I extended from SessionRepository. I'd like Redis to use this class rather than its SessionRepository. How can I implement it?

class SafeDeserializationRepository<S : Session?>(    private val delegate: SessionRepository<S>,    private val redisTemplate: RedisTemplate<Any, Any>) : SessionRepository<S> {    override fun createSession(): S {        return delegate.createSession()    }    override fun save(session: S) {        delegate.save(session)    }    override fun findById(p0: String?): S? {        return try {            delegate.findById(p0)        } catch (e: Exception) {            println("Deleting non-deserializable session with key $p0")            redisTemplate.delete(BOUNDED_HASH_KEY_PREFIX + p0)            null        }    }    override fun deleteById(p0: String?) {        delegate.deleteById(p0)    }    companion object {        private const val BOUNDED_HASH_KEY_PREFIX = "spring:session:sessions:"    }}

Viewing all articles
Browse latest Browse all 2223

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>