Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以在 django 中缓存具有不同类型对象的列表吗?当我尝试这样做时,django 总是返回 None 给我。
检查此代码:
foo = Foo.objects.all()[:10] bar = Bar.objects.all()[:10] foobar = list(foo) + list(bar) cache.set('foobar', foobar) cache.get('foobar') # None
如果这是正常行为,是否有一些解决方法?
Django可以缓存这样的列表,你需要检查
cache.set('foo', 'bar')
get
set
foobar