Hi,
I need to return a rather big file (11MB) to the user. For certain reasons, I can't just provide a direct url to the file (http://www.sample.com/mybigfile.exe); instead it must be accessed through code.
Instead of having to read it from disk over and over, I thought of saving it in memcached (if this is not a good idea, let me know). Everything seems to work, fine (no errors), but when I try to retrieve the file from memcached I always get None, as if the file wasn't cached.
Is there a size limit to what can be saved?
Here's the code:
def download_demo():
"""
Returns the demo file
"""
KEY = "xyz"
TIME = 86400 #24 hours
buff = memc.get(KEY)
if not buff:
file = open(FILENAME, 'r')
buff = file.read()
memc.set(KEY, buff, TIME)
print "Content-Type:application/x-download\nContent-Disposition:attachment;filename=%s\nContent-Length:%s\n\n%s" % (os.path.split(FILENAME)[-1], len(buff), buff)