News combit Dev Blog

New DataProvider for Redis

Posted: Tuesday, January 29, 2019 | 0 comment(s)
 
Redis is an in-memory key-value database, so a typical NoSQL database. Since its initial release in 2009, it has become quite popular and now is, according to db-engines.com by far the most popular key-value database out there. With the new RedisDataProvider you can now use your Redis database within List & Label or Report Server.

Getting Started

You need to add a reference to combit.ListLabel24.RedisDataProvider.dll and StackExchange.Redis (NuGet) in your project.

For a simple connection without any registered hash tables (for hash tables see below) you just need to create an instance of RedisDataProvider and specify the connection information in the constructor (options documentation: https://stackexchange.github.io/StackExchange.Redis/Configuration#configuration-options):

var provider = new RedisDataProvider.RedisDataProvider("<YourServerURL or IP>");
ListLabel ll = new ListLabel();
ll.DataSource = provider;
ll.Design();

 

Using a Hash Table

Because Redis is a key-value database, it does not have regular tables as you would expect from a schematized RDBMS. Every entry is a unique key, therefore in Redis, a table consists of many keys which belong to one table: e. g. "user:001", "user:002", ...

Since List & Label can't know how the database is structured and could only guess which key belongs to which table, you need to define the layout for every hash table you want to use.

This can be done easily by adding a new lambda to the RegisteredHashTables. If RegisteredHashTables contains any values, every database collection key will be delegated to the lambda. Then you can check with your own specified schema, if the delegated key belongs to any table. If it belongs to a table, you need to return the table name or String.Empty/null if the key does not match any table. 

Example

var provider = new RedisDataProvider.RedisDataProvider("<YourServerURL or IP>");
provider.RegisteredHashTables.Add((s) =>
{
    if (s.StartsWith("user"))
        return "user";
    return null;
});

 

Usage in the Report Server

For using Redis with the Report Server you need to add the data source "Redis" (under the category NoSQL). You need to at least specify the connection string for the data source (options documentation: https://stackexchange.github.io/StackExchange.Redis/Configuration#configuration-options).

If you want to use hash tables you need to specify the way the hash tables should be registered. For registering a hash table you must specify the value which the selected compare-function will check against and that will also be used as the table's name.

Example


This configuration connects to the Redis server at 192.168.10.204, registers the hash tables "user" and "items" (separated by "|") and uses the value as input for the compare-function (Starts with) and as the resulting table name.

To make this example clearer, this configuration translated to code (simplified) would look like this:

var provider = new RedisDataProvider.RedisDataProvider("192.168.10.204"); // connection string
provider.RegisteredHashTables.Add((s) =>
{
    if (s.StartsWith("user"))
        return "user";
    return null;
});
provider.RegisteredHashTables.Add((s) =>
{
    if (s.StartsWith("items"))
        return "items";
    return null;
});

 

Currently Supported Data Structures

Name Supported
Bitmaps
Hash
HyperLogLogs 
List
Set
SortedSet
String

 

Additional Information

  • Supported since List & Label 24.001
  • Supported since Report Server 24.001
  • Minimum .NET Framework Version: 4.6.1

The RedisDataProvider is IDisposable. Make sure to Dispose() the provider after usage. The sources for the provider are also available on our GitHub repository if you need to build against a different version.




Author: Jochen Bartlau
Head of Development List & Label

Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.


  

RSS
combit Development BlogRSS
What’s this blog for?
A place to share updates about the ongoing development of our products. General musings on the software industry included.
Archive
June 2021 (1)
May 2021 (1)
April 2021 (2)
March 2021 (1)
February 2021 (2)
January 2021 (1)
December 2020 (2)
November 2020 (1)
October 2020 (2)
September 2020 (1)
August 2020 (2)
July 2020 (1)
June 2020 (1)
May 2020 (2)
April 2020 (2)
March 2020 (2)
February 2020 (1)
January 2020 (1)
December 2019 (1)
November 2019 (2)
October 2019 (2)
September 2019 (2)
August 2019 (2)
July 2019 (2)
June 2019 (2)
May 2019 (1)
April 2019 (0)
April 2019 (1)
March 2019 (1)
February 2019 (1)
January 2019 (1)
December 2018 (1)
November 2018 (2)
October 2018 (4)
September 2018 (4)
August 2018 (2)
July 2018 (2)
June 2018 (2)
May 2018 (1)
April 2018 (1)
March 2018 (1)
February 2018 (2)
January 2018 (1)
December 2017 (1)
November 2017 (2)
October 2017 (3)
September 2017 (3)
August 2017 (2)
July 2017 (2)
June 2017 (1)
May 2017 (2)
April 2017 (1)
March 2017 (1)
February 2017 (1)
January 2017 (2)
December 2016 (1)
November 2016 (1)
October 2016 (4)
September 2016 (5)
August 2016 (2)
July 2016 (2)
June 2016 (3)
May 2016 (2)
April 2016 (3)
March 2016 (3)
February 2016 (1)
January 2016 (2)
December 2015 (2)
November 2015 (1)
October 2015 (4)
September 2015 (5)
August 2015 (2)
July 2015 (2)
June 2015 (2)
May 2015 (1)
April 2015 (2)
March 2015 (1)
February 2015 (1)
January 2015 (1)
December 2014 (2)
November 2014 (1)
October 2014 (1)
September 2014 (2)
August 2014 (1)
July 2014 (2)
June 2014 (1)
May 2014 (2)
April 2014 (1)
March 2014 (2)
+1 800 256 3608 (toll-free North America only)