1

I have searched the documentation but have not found what is put into the redis database (if anything) to track the "GetNextSequence" for an IRedisTypedClient. This came up because I started to see additional keys other than my own keys. I am not sure if I'm doing something wrong to get these extra keys, or if it is ServiceStack's way of tracking certain values. If it is, I'd like to know when it does this so I know what all the "breadcrumbs" are that are showing up.

Here is my simplified example:

private IRedisTypedClient<BucketInfo> redisBucket;
redisBucket = Redis.As<BucketInfo>();
var newBucketInfo = new BucketInfo {
    DB = redisBucket.GetNextSequence (),
    policy = bucketPolicy,
};

When it executes the GetNextSequence it puts seq:BucketInfo into the redis database before I even do any storage myself. Is this as expected?

Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
tradetree
  • 354
  • 3
  • 20
  • I just realized that I probably can't "GetNextSequence" on a string type object, so this operation only makes sense on a List type object. I'll test this and post the result. – tradetree Feb 24 '15 at 22:30
  • I guess I'm having a conversation with myself, but in any case GetNextSequence is not limited to a List object. It does appear it puts values into the Redis database to track the GetNextSequence. This comment by mythz on another answer supports that idea: "Ids are always sequential. They use Redis's INCR command" – tradetree Feb 26 '15 at 16:06
  • There is an open question here, that being where is the documentation on what ServiceStack.Redis puts into the redis database that are not directly the users keys? I have not found this anywhere other than I suppose the source code, if I knew what to look for. There are very confusing things showing up in my Redis DB like sets of ids. How many ids and under what conditions will these ids show up? I could fill the database with ids if I don't know why or when they show? – tradetree Feb 27 '15 at 16:18

1 Answers1

1

IRedisTypedClient<T>.GetNextSequence() is very simple operation - it just increments a value stored in SequenceKey key (by default it is named "seq:TypeName"). So in your case this operation is translated into

INCR seq:BucketInfo

Here is implementation, but you also can easily check what is going on behind the scenes with Redis MONITOR command. It streams back to Redis client all commands processed by Redis server.

Note that this value is not incremented if you do not call GetNextSequence(). I.e. if you store entity with id other than received from GetNextSequence() then the id will be added to entities ids set, and entity will be stored, but this will not affect next generated id. And vice versa - you can call GetNextSequence() without assigning the returned value to the entity you store. That will only increment next id.

So if you see some additional keys, then most likely you stored some entities without assigning sequential id generated by Redis.

Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459