EzDevInfo.com

RedisClient

Java Redis Client GUI Tool

ServiceStack.Redis stores empty object in the cache

I'm trying to implement a redis cache for my c# project. I used redisClient which is good to store normal datatypes like int and strings but not for storing objects. Then I moved to RedisTypedClient which should store my object in redis but it stores an empty object. And when i try to retrieve that object, it creates a new object and returns that.

Here's my test code which i'm trying to get to work but it's not working.

internal class Test
{
    public int a;
    public int b;
    public string s;

    public void show()
    {
        Console.WriteLine(a + "  " + b + "  " + s);
    }
}

public class Program
{
    private static void Main(string[] args)
    {
        using (var redisClient = new RedisClient("localhost"))
        {
            var t = new List<Test>();

            t.Add(new Test {a = 1, b = 2});
            t.Add(new Test {a = 3, b = 4});

            var key = "e";

            var rtest = redisClient.As<Test>();

            rtest.Store(t[0]).show();

            Console.WriteLine(t[0].GetId());
            var q = rtest.GetById(t[0].GetId());
        }

        Console.ReadKey();
    }

I have also tried using redis list.

IRedisList<Test> tl = rtest.Lists["testl"];
tl.Add(new Test { a = 1, b = 2 }); 
tl.Add(new Test { a = 3, b = 4 });
var rlist = rtest.Lists["testl"];

But the same thing happens in this case also. It stores empty objects.

I'm new to redis on windows and it may be possible that I'm making some mistake. But I can't get it to work. Any help will be greatly appreciated.


Source: (StackOverflow)

How can I view all the stored session's REDIS keys and values in .Net application?

Session["User"] = "LTA";

I used this session in my application. I am unable to view this stored session values in .net application. I tried in below way:

ConnectionMultiplexer redisConnection = ConnectionMultiplexer.Connect("hostname,ssl=true,password=privatekey,allowAdmin=true");

var redisServer = redisConnection.GetServer("hostname", port);

Here I can able to get key list and client list by using below code:

redisServer.Keys()
redisServer.ClientList()

but key values are shows like

\skdkhciduhcahoaids_Data

\skdkhciduhcahoaids_Internal

Is this encrypted key values? (This is my first query)

Then, This result doesn't change if I open the application in multiple browsers. But actually I want need 4 results if I open the application in 2 browsers because 2 session has been handled when the application run in 2 browsers.

Why it gives same result?

Can I able to view stored session values in redis connection? if yes means How can I view the session values?

Thanks in advance.....


Source: (StackOverflow)

Advertisements

Error ServiceStack.Redis.RedisException: Exceeded timeout of 00:00:03

I'm trying to read and write some objects in redis using last version of ServiceStack library. This is the code to initialize the client:

    string[] endpoints = Settings.Istance.RedisServers.Split(',');
    string[] slave = Settings.Istance.RedisServersSlave.Split(',');

    config.DefaultDb =0;
    config.AutoStart = true;
    config.MaxReadPoolSize = Convert.ToInt32(slave.Length);
    config.MaxWritePoolSize = Convert.ToInt32(endpoints.Length);

    PooledRedisClientManager pooledClientManager = new PooledRedisClientManager(endpoints, slave, config);

redisClientInt = pooledClientManager.GetClient() as RedisClient;

I received a lot of these error and My server go down for the load: ServiceStack.Redis.RedisException: Exceeded timeout of 00:00:03 ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:6379

The ip addres of my redis server isn't 127.0.0.1:6379 but it have a specific IP saved in endpoints variable. I don't understund why the client call localhost.

Can you help me? I'm doing something of wrong in the call or in configuration?

TY and regards, Giuseppe


Source: (StackOverflow)

C++ RedisClient : how does RedisValue.toInt() is suppose to work?

This is about RedisClient, which is a C++ client.

I know that you can't store integers in Redis (that are internally converted).

RedisSyncClient::command itself does not support integers as RedisBuffer can't be initialized with int, so:

redis->command("SET", "mykey", 1);

won't compile (you need to add numbers as string).

However RedisValue can be initialized with int (not sure when it is used) and it contains a public "toInt()" method:

redis->command("SET", "mykey", "1"); result = redis->command("GET", "mykey"); cout << "INT: " << result.toInt() << " , STR: " << result.toString() << endl;

INT: 0 , STR : 1

At first I thought that internally strings were being converted to int, but it always return "0". Testing "RedisValue.isInt()" it seems it fails to recognize numbers as it returns "false".

  • What is the intention of "toInt()" if numbers are only seen (by this library) as strings?
  • Am I using it incorrectly?
  • Is this a work-in-progress feature?

Source: (StackOverflow)