There are two ways to secure bulk pop data:
1. Using transactions (without a transaction may result in repeated reads.) The pipeline of Servicestack is not self-bringing business. )
2. Execute LUA Script
Here I provide a way to implement the transaction:
public static string ReadLine (Redisnativeclient cln) {MethodInfo mi = cln. GetType (). GetMethod ("ReadLine", BindingFlags.NonPublic | bindingflags.instance); string ret = (string) mi. Invoke (CLN, new object[] {}); return ret;} public static list<string> Batchdequeue (Redisnativeclient cln, string listID, int max_count) {list<string> ret = new list<string> (), var ulistid = Encoding.UTF8.GetBytes (ListID), var pipeline = Cln. Createpipelinecommand ();p ipeline. Writecommand (Commands.multi);p ipeline. Writecommand (Commands.lrange, Ulistid, Encoding.UTF8.GetBytes ("0"), Encoding.UTF8.GetBytes ((max_count-1). ToString ()));p Ipeline. Writecommand (Commands.ltrim, Ulistid, Encoding.UTF8.GetBytes (max_count. ToString ()), Encoding.UTF8.GetBytes ("-1"));p Ipeline. Writecommand (commands.exec);p ipeline. Flush (); var a1 = ReadLine (CLN);//Ignore multi Okvar a2 = ReadLine (CLN);//Ignore Lrange Queuedvar = A3 (ReadLine);// Ignore ltrim queuedvar a4 = ReadLine (CLN);//ignore *2var B = cln. Receivemessages (); foreach (var item in b) {string SS = Encoding.UTF8.GetString (item); Ret. ADD (ss);} ReadLine (CLN);//Ignore exec's okreturn ret;}
[C #] Servicestack.redis How to batch pop data?