Skip to content

Instantly share code, notes, and snippets.

@Jonahss
Last active March 31, 2018 23:21
Show Gist options
  • Save Jonahss/a8cf79fb71830b28e8b413d8acbaa742 to your computer and use it in GitHub Desktop.
Save Jonahss/a8cf79fb71830b28e8b413d8acbaa742 to your computer and use it in GitHub Desktop.
Redis AddToList
using System;
using ServiceStack;
using ServiceStack.Text;
using ServiceStack.Redis;
using ServiceStack.DataAnnotations;
var redisManager = new RedisManagerPool("localhost:6379");
var redis = redisManager.GetClient();
// let's make sure this key doesn't exist first
redis.RemoveEntry("myList");
// this demonstrates that items can be appended to the list,
// even if the list itself isn't defined yet
redis.AddItemToList("myList", "1");
redis.AddItemToList("myList", "2");
redis.AddItemToList("myList", "3");
var list = redis.GetAllItemsFromList("myList");
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.0.2" targetFramework="net45" />
<package id="ServiceStack.Redis" version="5.0.2" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment