using redis-py to bulk populate a redis list
<p>In a Django project, I'm using redis as a fast backend. </p>

<p>I can LPUSH multiple values in a redis list like so:</p>

<pre><code>lpush(list_name,"1","2","3")
</code></pre>

<p>However, I can't do it if I try</p>

<pre><code>values_list = ["1","2","3"]
lpush(list_name,values_list)
</code></pre>

<p>For the record, this doesn't return an error. Instead it creates a list <code>list_name</code> with a single value. E.g. <code>['["1","2","3"]']</code>. This is not usable if later one does <code>AnObject.objects.filter(id__in=values_list)</code>. Nor does it work if one does <code>AnObject.objects.filter(id__in=values_list[0])</code> (error: invalid literal for int() with base 10: '[').</p>

<p>What's the best way to LPUSH numerous values in bulk into a redis list (python example is preferred). </p>

<p><code>lpush (list_name, *values_list)</code></p>

<p>This will unpack contents in value_list as parameters.</p>

<p>If you have enormous numbers of values to insert into db, you can pipeline them. Or you can use the command line tool <code>redis-cli --pipe</code> to populate a database</p>

python django redis