{"action":"created","issue":{"url":"https://api.github.com/repos/Suor/django-cacheops/issues/134","labels_url":"https://api.github.com/repos/Suor/django-cacheops/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/Suor/django-cacheops/issues/134/comments","events_url":"https://api.github.com/repos/Suor/django-cacheops/issues/134/events","html_url":"https://github.com/Suor/django-cacheops/pull/134","id":58969594,"number":134,"title":"First implementation of dog-pile effect avoidance via python-redis-lock additions","user":{"login":"Karmak23","id":663404,"avatar_url":"https://avatars.githubusercontent.com/u/663404?v=3","gravatar_id":"","url":"https://api.github.com/users/Karmak23","html_url":"https://github.com/Karmak23","followers_url":"https://api.github.com/users/Karmak23/followers","following_url":"https://api.github.com/users/Karmak23/following{/other_user}","gists_url":"https://api.github.com/users/Karmak23/gists{/gist_id}","starred_url":"https://api.github.com/users/Karmak23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Karmak23/subscriptions","organizations_url":"https://api.github.com/users/Karmak23/orgs","repos_url":"https://api.github.com/users/Karmak23/repos","events_url":"https://api.github.com/users/Karmak23/events{/privacy}","received_events_url":"https://api.github.com/users/Karmak23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-25T21:05:01Z","updated_at":"2015-02-26T03:21:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Suor/django-cacheops/pulls/134","html_url":"https://github.com/Suor/django-cacheops/pull/134","diff_url":"https://github.com/Suor/django-cacheops/pull/134.diff","patch_url":"https://github.com/Suor/django-cacheops/pull/134.patch"},"body":"Hi @Suor,\r\n\r\nhere is a patch to enable dog-pile avoidance in `cacheops`.\r\n\r\nCould you please review it and see if I didn't miss anything ?\r\n\r\nThis patched version has been running for hours on my 1flow development machine without problems.\r\n\r\nI will deploy it on http://1flow.io/ at next major release.\r\n\r\nI patched `simple` & `query`, and didn't find any other obvious locations to patch.\r\n\r\nYour feedback is appreciated.\r\n\r\nRegards,"},"comment":{"url":"https://api.github.com/repos/Suor/django-cacheops/issues/comments/76115729","html_url":"https://github.com/Suor/django-cacheops/pull/134#issuecomment-76115729","issue_url":"https://api.github.com/repos/Suor/django-cacheops/issues/134","id":76115729,"user":{"login":"Suor","id":284103,"avatar_url":"https://avatars.githubusercontent.com/u/284103?v=3","gravatar_id":"","url":"https://api.github.com/users/Suor","html_url":"https://github.com/Suor","followers_url":"https://api.github.com/users/Suor/followers","following_url":"https://api.github.com/users/Suor/following{/other_user}","gists_url":"https://api.github.com/users/Suor/gists{/gist_id}","starred_url":"https://api.github.com/users/Suor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suor/subscriptions","organizations_url":"https://api.github.com/users/Suor/orgs","repos_url":"https://api.github.com/users/Suor/repos","events_url":"https://api.github.com/users/Suor/events{/privacy}","received_events_url":"https://api.github.com/users/Suor/received_events","type":"User","site_admin":false},"created_at":"2015-02-26T03:21:16Z","updated_at":"2015-02-26T03:21:16Z","body":"Thinking a bit more about it I came up with this procedure:\r\n```python\r\nresult = None\r\nresult_p = cache_get(cache_key)\r\n\r\nwhile result_p is None and result is None:\r\n    lock = Lock(redis_conn, cache_key, expire=1)\r\n    if lock.acquire(blocking=False):\r\n        result = calculate()\r\n        cache_set(cache_key, result)\r\n    else:\r\n        with lock:\r\n            result_p = cache_get(cache_key)\r\n\r\nreturn result or pickle.loads(result_p)\r\n```"}}