redis_utils.py

About this file

This file contains the utils for using Redis. The functions included in this file pertain to storing a file's metadata, returning the stored file's metadata, obtaining the file's upload key, returning the user session ID. A file's metadata includes the file size, mime type, and hash.

Function 'redis_set_file_metadata(request_or_response_id, filepath, is_update=False)' stores a file's size, mime type, and hash.

Function 'redis_get_file_metadata(request_or_response_id, filepath, is_update=False)' returns a tuple containing a file's size (int), mime type (str) and hash (str).

Code Issues

  • Use of modules cPickle and pickle is associated with security implications (line 5). It is normally avoided unless used cautiously. More information can be found here.

Code Check Report


No problems to report
                        

Documentation drawn from source code


redis_set_file_metadata(request_or_response_id, filepath, is_update=False):

Stores a file's size, mime type, and hash.

redis_get_file_metadata(request_or_response_id, filepath, is_update=False):

Returns a tuple containing a file's
( size (int), mime type (str), and hash (str) ).

redis_delete_file_metadata(request_or_response_id, filepath, is_update=False):

_get_file_metadata_key(request_or_response_id, filepath, is_update):

See upload.utils.get_upload_key

Since this key is being stored in upload_redis, a pipe
is used instead of an underscore to avoid any key conflicts.

redis_get_user_session(session_id):

redis_delete_user_session(session_id):

Source code