{"action":"created","issue":{"url":"https://api.github.com/repos/niwinz/django-redis/issues/193","repository_url":"https://api.github.com/repos/niwinz/django-redis","labels_url":"https://api.github.com/repos/niwinz/django-redis/issues/193/labels{/name}","comments_url":"https://api.github.com/repos/niwinz/django-redis/issues/193/comments","events_url":"https://api.github.com/repos/niwinz/django-redis/issues/193/events","html_url":"https://github.com/niwinz/django-redis/issues/193","id":154985341,"number":193,"title":"return value of cache.ttl() is None","user":{"login":"ayasiee","id":19385193,"avatar_url":"https://avatars.githubusercontent.com/u/19385193?v=3","gravatar_id":"","url":"https://api.github.com/users/ayasiee","html_url":"https://github.com/ayasiee","followers_url":"https://api.github.com/users/ayasiee/followers","following_url":"https://api.github.com/users/ayasiee/following{/other_user}","gists_url":"https://api.github.com/users/ayasiee/gists{/gist_id}","starred_url":"https://api.github.com/users/ayasiee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayasiee/subscriptions","organizations_url":"https://api.github.com/users/ayasiee/orgs","repos_url":"https://api.github.com/users/ayasiee/repos","events_url":"https://api.github.com/users/ayasiee/events{/privacy}","received_events_url":"https://api.github.com/users/ayasiee/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/niwinz/django-redis/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-16T08:41:29Z","updated_at":"2016-05-17T03:01:51Z","closed_at":null,"body":"Hi.\r\n\r\nI'm use django-redis to use cache. and my python version is 3.4.3.\r\n\r\nI have a problem with return value of cache.ttl() is None although key/val is not persistent.\r\n\r\nthe point is\r\n`(t >= 0 and t or None)`\r\nhttps://github.com/niwinz/django-redis/blob/master/django_redis/client/default.py#L424\r\n\r\n\r\nwhen t is 0, this statement returns None.\r\n\r\nwould you please modify this code to like:\r\n\r\n```\r\nif t >=0\r\n return t\r\nelse:\r\n return None\r\n```\r\n\r\nthanks"},"comment":{"url":"https://api.github.com/repos/niwinz/django-redis/issues/comments/219607652","html_url":"https://github.com/niwinz/django-redis/issues/193#issuecomment-219607652","issue_url":"https://api.github.com/repos/niwinz/django-redis/issues/193","id":219607652,"user":{"login":"ayasiee","id":19385193,"avatar_url":"https://avatars.githubusercontent.com/u/19385193?v=3","gravatar_id":"","url":"https://api.github.com/users/ayasiee","html_url":"https://github.com/ayasiee","followers_url":"https://api.github.com/users/ayasiee/followers","following_url":"https://api.github.com/users/ayasiee/following{/other_user}","gists_url":"https://api.github.com/users/ayasiee/gists{/gist_id}","starred_url":"https://api.github.com/users/ayasiee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ayasiee/subscriptions","organizations_url":"https://api.github.com/users/ayasiee/orgs","repos_url":"https://api.github.com/users/ayasiee/repos","events_url":"https://api.github.com/users/ayasiee/events{/privacy}","received_events_url":"https://api.github.com/users/ayasiee/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T03:01:51Z","updated_at":"2016-05-17T03:01:51Z","body":"thanks for your reply.\r\n\r\ni can pull request but i didn't. because there is 2 choices. and i can not decide which is correct.\r\n\r\nlet me see.\r\nin document (http://niwinz.github.io/django-redis/latest/#_get_ttl_time_to_live_from_key)\r\n\r\n```\r\nIt returns:\r\n\r\n* ttl value for any volatile key (any key that has expiration)\r\n* 0 for expired and not existent keys\r\n* None for keys that does not have expiration\r\n```\r\n0 is confusing.\r\n1. if key does not exists or expired, returns 0\r\n2. value for any volatile key which ttl is less than 1 seconds\r\n\r\nif you choose backward compatibility,\r\n```\r\n  if t>=0:\r\n    return t\r\n  else:\r\n    return None\r\n```\r\nis enough. but confusing 0 is left.\r\n\r\nif you choose solve confusing 0,\r\n```\r\n  t=client.pttl(key)\r\n  if t > 1000:\r\n    return int(t/1000)  \r\n  elif t > 0:\r\n    return t/1000\r\n  else:\r\n    return None\r\n```\r\nis one of the solution. (if ttl < 1, ttl is float)\r\n\r\nhow about your opinion?"}}