{"action":"created","issue":{"url":"https://api.github.com/repos/mbr/simplekv/issues/23","labels_url":"https://api.github.com/repos/mbr/simplekv/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/mbr/simplekv/issues/23/comments","events_url":"https://api.github.com/repos/mbr/simplekv/issues/23/events","html_url":"https://github.com/mbr/simplekv/issues/23","id":64564005,"number":23,"title":"Float TTL does not work with memcached pylibmc","user":{"login":"flaker","id":627517,"avatar_url":"https://avatars.githubusercontent.com/u/627517?v=3","gravatar_id":"","url":"https://api.github.com/users/flaker","html_url":"https://github.com/flaker","followers_url":"https://api.github.com/users/flaker/followers","following_url":"https://api.github.com/users/flaker/following{/other_user}","gists_url":"https://api.github.com/users/flaker/gists{/gist_id}","starred_url":"https://api.github.com/users/flaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flaker/subscriptions","organizations_url":"https://api.github.com/users/flaker/orgs","repos_url":"https://api.github.com/users/flaker/repos","events_url":"https://api.github.com/users/flaker/events{/privacy}","received_events_url":"https://api.github.com/users/flaker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-26T15:51:43Z","updated_at":"2015-03-27T15:23:12Z","closed_at":null,"body":"Hi,\r\n\r\nI was moving some project from a test scenario to use simplekv with memcache and pylibmc. SimpleKV tries to intercept bad ttl values by checking for [int, float] but in any case, the call to pylibmc `set`will result in an error if  float value is used.\r\n\r\nSample code follows:\r\n\r\n```python\r\nimport pylibmc\r\nfrom simplekv.memory import memcachestore\r\n\r\nmc = pylibmc.Client([\"127.0.0.1\"], binary=True, behaviors={\"tcp_nodelay\": True, \"ketama\": True})\r\nstore = memcachestore.MemcacheStore(mc)\r\nstore.put(\"the_key\", \"the_data\", ttl_secs=3.4)\r\n```\r\n\r\nThe result is:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"prueba.py\", line 6, in <module>\r\n    store.put(\"the_key\", \"the_data\", ttl_secs=3.4)\r\n  File \"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/simplekv/__init__.py\", line 374, in put\r\n    return self._put(key, data, self._valid_ttl(ttl_secs))\r\n  File \"/Users/fdelgado/dev/Bouncer/venv/lib/python2.7/site-packages/simplekv/memory/memcachestore.py\", line 53, in _put\r\n    if not self.mc.set(key.encode('ascii'), data, time=time):\r\nTypeError: integer argument expected, got float\r\n```\r\n\r\nThe libs used are:\r\n * simplekv==0.9.2\r\n * pylibmc==1.4.1\r\n\r\nagainst memcache 1.4.14.\r\n\r\nI understand that memcache ttl is an unix timestamp. That should be whole seconds, right?\r\n\r\nThanks for any help.\r\n\r\nFederico"},"comment":{"url":"https://api.github.com/repos/mbr/simplekv/issues/comments/86973294","html_url":"https://github.com/mbr/simplekv/issues/23#issuecomment-86973294","issue_url":"https://api.github.com/repos/mbr/simplekv/issues/23","id":86973294,"user":{"login":"mbr","id":110577,"avatar_url":"https://avatars.githubusercontent.com/u/110577?v=3","gravatar_id":"","url":"https://api.github.com/users/mbr","html_url":"https://github.com/mbr","followers_url":"https://api.github.com/users/mbr/followers","following_url":"https://api.github.com/users/mbr/following{/other_user}","gists_url":"https://api.github.com/users/mbr/gists{/gist_id}","starred_url":"https://api.github.com/users/mbr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbr/subscriptions","organizations_url":"https://api.github.com/users/mbr/orgs","repos_url":"https://api.github.com/users/mbr/repos","events_url":"https://api.github.com/users/mbr/events{/privacy}","received_events_url":"https://api.github.com/users/mbr/received_events","type":"User","site_admin":false},"created_at":"2015-03-27T15:23:12Z","updated_at":"2015-03-27T15:23:12Z","body":"A unix timestamp is usually an integer, but sometimes it is not (Python, for example, uses float timestamps). I've checked the memcached protocol and in my understanding memcached expects an integer.\r\n\r\nSince for that reason it is impossible to have great-than-second accuracy for these things anyway, I've added a cast-to-int. If the tests pass (which I hope they do), could you check if 3709f90c6ef1d2421a11d4ac8b631a587f349814 fixes things for you?"}}