Implemented Cache for decrypted private key and handled refresh token
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.skycrate.backend.skycrateBackend.services;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Service
|
||||
public class KeyCacheService {
|
||||
|
||||
private final ConcurrentHashMap<Long, String> keyCache = new ConcurrentHashMap<>();
|
||||
|
||||
public void cacheKey(Long userId, String decryptedKey) {
|
||||
keyCache.put(userId, decryptedKey);
|
||||
}
|
||||
|
||||
public String getKey(Long userId) {
|
||||
return keyCache.get(userId);
|
||||
}
|
||||
|
||||
public void clearKey(Long userId) {
|
||||
keyCache.remove(userId);
|
||||
}
|
||||
|
||||
public void clearAllKeys() {
|
||||
keyCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user