Skip to content

dhanilan/RedisAutocompleter

Repository files navigation

RedisAutocompleter

Autocomplete with Redis , C#
Implementation of Autocomplete as described in blog post by creater of Redis in in C#
Implemented by using ZRANK and ZRANGE on sorted sets . Complexity is O(log(N)) .More details can be found on the blog post.

Installation

Install-Package RedisAutocomplete  

Note:Nuget package supports only Version 4.5.2 of dot net currently. More targets will be added.

Config settings

 <connectionStrings>  
    <add name="DefaultRedisAutocomplete" connectionString="localhost:6379"/>  
    <add name="AlternateRedisAutocomplete" connectionString="localhost:6378"/>  
  </connectionStrings>

Usage

       var autocompleter = new RedisAutoComplete<string>();/*var autocompleter = new RedisAutoComplete<string>("AlternateRedisAutocomplete"); */
        var input = new List<string>();
        input.Add("foo");
        input.Add("foobar");
        input.Add("bar");
        input.Add("icecream");
        autocompleter.SetValues(input);
        var result = autocompleter.GetValues("foo");
        Assert.AreEqual(result.Count, 2);
        Assert.AreEqual(result[0], "foo");
        Assert.AreEqual(result[1], "foobar");

About

Autocomplete with Redis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages