Conhecendo o cache Redis do Azure

Redis

Cache Redis do Azure

Criando um cache Redis no Azure

Usando o Redis

.NET

using System;  
using StackExchange.Redis;

namespace ConsoleApplication1
{
public class Program
{
private static void Main()
{
var conexao = @"testeblog.redis.cache.windows.net, ssl=true, password=e3zFsDIv0gWnThaXV6bydaCmGQBNP/55b2W1M/ZJ8UA=";
using (var connection = ConnectionMultiplexer.Connect(conexao))
{
var cache = connection.GetDatabase();

cache.StringSet("chave", "valor");
cache.StringSet("outra-chave", 10);

var chave = cache.StringGet("chave");
var outraChave = (int) cache.StringGet("outra-chave");

Console.WriteLine("chave: {0}", chave);
Console.WriteLine("outra-chave: {0}", outraChave);
}
}
}
}

Outros clientes

Node.js

var redis = require('redis');  
var client = redis.createClient(6379, 'testeblog.redis.cache.windows.net', {
auth_pass: 'e3zFsDIv0gWnThaXV6bydaCmGQBNP/55b2W1M/ZJ8UA='
});
var callback = function(erro, resposta) {
if(!erro) {
console.log(resposta);
}
};

client.set('chave-node', 'valor-node', callback);
client.set('outra-chave-node', 20, callback);
client.get('chave-node', callback);
client.get('outra-chave-node', function(e, r) {
callback(e, r);
client.end();
});

Linha de comando

c:\>choco install redis-64  
Chocolatey (v0.9.8.33) is installing 'redis-64' and dependencies. By installing you accept the license for 'redis-64' and each dependency you are installing.

Finished installing 'redis-64' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.

c:\>redis-cli -h testeblog.redis.cache.windows.net -a e3zFsDIv0gWnThaXV6bydaCmGQBNP/55b2W1M/ZJ8UA=
testeblog.redis.cache.windows.net:6379> ping
PONG
testeblog.redis.cache.windows.net:6379> set "chave-cmd" "valor-cmd"
OK
testeblog.redis.cache.windows.net:6379> get "chave-cmd"
"valor-cmd"
testeblog.redis.cache.windows.net:6379> get "chave"
"valor"
testeblog.redis.cache.windows.net:6379> get "chave-node"
"valor-node"
testeblog.redis.cache.windows.net:6379> exit

Monitoramento

Finalizando

--

--

--

Luís Rudge é pai e desenvolvedor há anos. Trabalha na Round Pegs Inc & seu projeto pessoal http://www.uniclearning.com.br/ — hospedado inteiramente no Azure

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luis Rudge

Luis Rudge

Luís Rudge é pai e desenvolvedor há anos. Trabalha na Round Pegs Inc & seu projeto pessoal http://www.uniclearning.com.br/ — hospedado inteiramente no Azure

More from Medium

Single UI solution for CAP library dashboards in microservice architecture

Rate Limiting using Kong API Gateway

Decouple Long-running Tasks from HTTP Request Processing — Scalable Consumers

.Net 6 Publish to Kafka topic (efficiently)