Created
March 19, 2024 06:47
-
-
Save alexjosesilva/a43dc6412c42bafb61ed21cc092fbdbc to your computer and use it in GitHub Desktop.
Quando o cliente envia uma solicitação, o servidor verifica se há dados em cache para essa solicitação
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis.clients.jedis.Jedis; | |
public class RedisCacheExemplo { | |
public static void main(String[] args) { | |
// Conecta ao servidor Redis local | |
Jedis jedis = new Jedis("localhost"); | |
// Armazena dados no cache com uma chave e um valor | |
jedis.set("chave", "dados"); | |
// Recupera dados do cache usando a chave | |
String dados = jedis.get("chave"); | |
// Imprime os dados recuperados do cache | |
System.out.println("Dados do cache: " + dados); | |
// Fecha a conexão com o servidor Redis | |
jedis.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment