ServiceStack.Redis question?

87 views
Skip to first unread message

Kevin Burton

unread,
Nov 9, 2012, 5:43:44 PM11/9/12
to redi...@googlegroups.com
First is there a ServiceStack.Redis forum? Where can I get more detailed information?

I noticed in the examples

    //Create a 'strongly-typed' API that makes all Redis Value operations to apply against Shippers
    IRedisTypedClient<Shipper> redis = redisClient.GetTypedClient<Shipper>();

    //Redis lists implement IList<T> while Redis sets implement ICollection<T>
    var currentShippers = redis.Lists["urn:shippers:current"];
    var prospectiveShippers = redis.Lists["urn:shippers:prospective"];


My question is when the dereferenced 'Lists' does not exist does it automatically create it for you?

Also from the Wiki, most of the samples use 'Add' but when it came to demonstrate speed 'StoreAll' is used. What is the difference? What am I giving up for speed?

Thank you.

Demis Bellot

unread,
Nov 9, 2012, 6:20:07 PM11/9/12
to redi...@googlegroups.com
>> First is there a ServiceStack.Redis forum?

Sure, any ServiceStack Redis questions should go on StackOverflow (with redis + servicestack hash tags). Any bugs/issues should go to on the project's GitHub issues.

>> My question is when the dereferenced 'Lists' does not exist does it automatically create it for you?

It does nothing server-side, it just returns a typed wrapper API around a redis server-side list. Only when you modify collections or persist/read data does the Redis client make a call.

>>Also from the Wiki, most of the samples use 'Add' but when it came to demonstrate speed 'StoreAll' is used. What is the difference? What am I giving up for speed?

StoreAll uses MSET under the hood which is a batchful operation only requiring 1 socket write + 1 socket read rather than a socket write/read per operation that would be done if you use Add for every element.
Whenever you see batch-ful APIs in ServiceStack.Redis that you can use, use those instead - as they'll use the more efficient redis server APIs when they exist.

Most of these questions can be answered by checking the source for ServiceStack.Redis which is all on GitHub and IMO is very readable. 



--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/MiJ6BsGXlR0J.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.



--
- Demis


Kevin Burton

unread,
Nov 11, 2012, 5:25:54 PM11/11/12
to redi...@googlegroups.com
Thank you but I am still not sure of the answer. Do I have to worry about the list "urn:shippers:current" existing before it is dereferenced in the sample redis.List[] call? Or is there a specific 'CreateList' call that I have not found yet?

Demis Bellot

unread,
Nov 11, 2012, 7:05:41 PM11/11/12
to redi...@googlegroups.com
Redis is schema-less and operations against a non-existent collection is the same as an empty collection, i.e. if it doesn't exist, it'll get created on the fly.
Here's an explanation about the Redis data model from Salvatore's blog:

If an operation targeting an aggregate data type (list,set,zset,hash) is performed against a non existing key, the behavior should be exactly the one obtained running the operation against an empty aggregate value of the same type. So for instance LLEN returns 0 if called against a non existing key, because we consider it holding an empty list.

Please ask any future questions about the ServiceStack.Redis client on StackOverflow, using the servicestack + redis hashtags.

Thanks,




To view this discussion on the web visit https://groups.google.com/d/msg/redis-db/-/P2NrCn1Kd8wJ.

To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
Reply all
Reply to author
Forward
0 new messages