How do you confirm django is using memcached?

前端 未结 1 1754
甜味超标
甜味超标 2021-01-18 05:04

I have a python django webserver that I am trying to use memcached to make it faster.

I have downloaded and installed memcached and started it a user called virtual

1条回答
  •  南方客
    南方客 (楼主)
    2021-01-18 05:30

    You can test cache in Django's shell (python manage.py shell):

    >>> from django.core.cache import cache
    >>> cache.set('foo', 'bar', 600)
    >>> cache.get('foo')
    'bar'
    

    If cache.get() returns the set value it means that cache is working as it should. Otherwise it will return None.

    An other option is to start memcached with $ memcached -vv, since it will log all the cache accesses to the terminal. Or alternatively you can install monitoring tool for memcached (i.e. memcache-top) and check that something is happening in memcached while using your app.

    0 讨论(0)
提交回复
热议问题