Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>Update</em>, for global setting, check <a href="https://stackoverflow.com/a/12285706/165603">jmoz's answer</a>. </p> <p>If you're using third-party lib such as <code>django-redis</code>, you may need to specify a customized <code>ConnectionFactory</code>:</p> <pre><code>class DecodeConnectionFactory(redis_cache.pool.ConnectionFactory): def get_connection(self, params): params['decode_responses'] = True return super(DecodeConnectionFactory, self).get_connection(self, params) </code></pre> <hr> <p>Assuming you're using redis-py, you'd better to pass <code>str</code> instead of <code>unicode</code> to Redis, or else <a href="https://github.com/andymccurdy/redis-py/blob/master/redis/connection.py#L282" rel="nofollow noreferrer">Redis will encode it automatically</a> for <code>*set</code> commands, normally <a href="https://github.com/andymccurdy/redis-py/blob/master/redis/connection.py#L165" rel="nofollow noreferrer">in UTF-8</a>. For the <code>*get</code> commands, Redis has no idea about the formal type of a value and has to just return the value in <code>str</code> directly.</p> <p>Thus, As Denis said, the way that you storing the object to Redis is critical. You need to transform the value to <code>str</code> to make the Redis layer transparent for you.</p> <p>Also, <a href="https://stackoverflow.com/questions/7105441/how-to-set-default-encoding-in-pythonsetdefaultencoding-function-does-not-exist">set the default encoding to UTF-8</a> instead of using <code>ascii</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload