{"action":"created","comment":{"url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/comments/65779623","id":65779623,"diff_hunk":"@@ -0,0 +1,275 @@\n+package Mojo::Redis2::Cursor;\n+use Mojo::Base '-base';\n+\n+use Carp 'croak';\n+use Scalar::Util 'looks_like_number';\n+\n+has 'redis';\n+has _args => sub { [] };\n+has '_command';\n+has _cursor => 0;\n+\n+sub again {\n+  my $self = shift;\n+  $self->_cursor(0);\n+  delete $self->{_finished};\n+  return $self;\n+}\n+\n+sub command { shift->{_command}[0] }\n+\n+sub finished { !!shift->{_finished} }\n+\n+sub hgetall {\n+  my $cur = shift->_clone('HSCAN', shift);\n+  return $cur->slurp(@_);\n+}\n+\n+sub hkeys {\n+  my $cb = ref $_[-1] eq 'CODE' ? pop : undef;\n+  my $cur = shift->_clone('HSCAN' => @_);\n+  my $wrapper = sub {\n+    my $keys = [grep { $a = !$a } @{$_[2] || []}];\n+    return $cur->$cb($_[1], $keys);\n+  };\n+  my $resp = $cur->slurp($cb ? ($wrapper) : ());\n+  return $resp if $cb;\n+  $cb = sub { $_[2] };\n+  return $wrapper->(undef, '', $resp);\n+}\n+\n+sub key { shift->{_command}[1] }\n+\n+sub keys {\n+  my $cur = shift->_clone('SCAN');\n+  unshift @_, 'MATCH' if $_[0] && !ref $_[0];\n+  return $cur->slurp(@_);\n+}\n+\n+sub new {\n+  my $self    = shift->SUPER::new();\n+  my $command = shift;\n+  $self->_command($command eq 'SCAN' ? [$command] : [$command, shift]);\n+  croak 'ERR Should not specify cursor value manualy.'\n+    if looks_like_number $_[0];\n+  $self->_args(\\@_) if @_;\n+  return $self;\n+}\n+\n+sub next {\n+  my $cb = ref $_[-1] eq 'CODE' ? pop : undef;\n+  my $self = shift;\n+\n+  return undef if $self->{_finished};\n+\n+  my $args = @_ ? $self->_args(\\@_)->{_args} : $self->_args;\n+  my $wrapper = sub {\n+    my (undef, $err, $resp) = @_;\n+    $self->_cursor(my $cur = $resp->[0] // 0);\n+    $self->{_finished} = 1 if $cur == 0;\n+    return $self->$cb($err, $resp->[1]);\n+  };\n+\n+  my $resp = $self->redis->_execute(\n+    basic => @{$self->_command},\n+    $self->_cursor, @$args, $cb ? ($wrapper) : ()\n+  );\n+  return $resp if $cb;\n+  $cb = sub { $_[2] };\n+  return $wrapper->(undef, '', $resp);\n+}\n+\n+sub slurp {","path":"lib/Mojo/Redis2/Cursor.pm","position":82,"original_position":82,"commit_id":"ce776de7eb5ba362ef2132591e333078128cbad6","original_commit_id":"ce776de7eb5ba362ef2132591e333078128cbad6","user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"body":"What about calling it all() instead?","created_at":"2016-06-03T21:38:04Z","updated_at":"2016-06-03T21:38:04Z","html_url":"https://github.com/jhthorsen/mojo-redis2/pull/18#discussion_r65779623","pull_request_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/comments/65779623"},"html":{"href":"https://github.com/jhthorsen/mojo-redis2/pull/18#discussion_r65779623"},"pull_request":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18","id":72347675,"html_url":"https://github.com/jhthorsen/mojo-redis2/pull/18","diff_url":"https://github.com/jhthorsen/mojo-redis2/pull/18.diff","patch_url":"https://github.com/jhthorsen/mojo-redis2/pull/18.patch","issue_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/18","number":18,"state":"open","locked":false,"title":"Add *scan commands.","user":{"login":"anparker","id":1029549,"avatar_url":"https://avatars.githubusercontent.com/u/1029549?v=3","gravatar_id":"","url":"https://api.github.com/users/anparker","html_url":"https://github.com/anparker","followers_url":"https://api.github.com/users/anparker/followers","following_url":"https://api.github.com/users/anparker/following{/other_user}","gists_url":"https://api.github.com/users/anparker/gists{/gist_id}","starred_url":"https://api.github.com/users/anparker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anparker/subscriptions","organizations_url":"https://api.github.com/users/anparker/orgs","repos_url":"https://api.github.com/users/anparker/repos","events_url":"https://api.github.com/users/anparker/events{/privacy}","received_events_url":"https://api.github.com/users/anparker/received_events","type":"User","site_admin":false},"body":"Since #11 is a bit stalled, I made another implementation. Scan related commands will return cursor object, which will be used for iterations and cursor value handling.","created_at":"2016-06-02T13:39:04Z","updated_at":"2016-06-03T21:38:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea6177fc0571dac28015615f8963f088cde33fc9","assignee":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18/commits","review_comments_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18/comments","review_comment_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/18/comments","statuses_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/statuses/ce776de7eb5ba362ef2132591e333078128cbad6","head":{"label":"anparker:scan-commands","ref":"scan-commands","sha":"ce776de7eb5ba362ef2132591e333078128cbad6","user":{"login":"anparker","id":1029549,"avatar_url":"https://avatars.githubusercontent.com/u/1029549?v=3","gravatar_id":"","url":"https://api.github.com/users/anparker","html_url":"https://github.com/anparker","followers_url":"https://api.github.com/users/anparker/followers","following_url":"https://api.github.com/users/anparker/following{/other_user}","gists_url":"https://api.github.com/users/anparker/gists{/gist_id}","starred_url":"https://api.github.com/users/anparker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anparker/subscriptions","organizations_url":"https://api.github.com/users/anparker/orgs","repos_url":"https://api.github.com/users/anparker/repos","events_url":"https://api.github.com/users/anparker/events{/privacy}","received_events_url":"https://api.github.com/users/anparker/received_events","type":"User","site_admin":false},"repo":{"id":59827750,"name":"mojo-redis2","full_name":"anparker/mojo-redis2","owner":{"login":"anparker","id":1029549,"avatar_url":"https://avatars.githubusercontent.com/u/1029549?v=3","gravatar_id":"","url":"https://api.github.com/users/anparker","html_url":"https://github.com/anparker","followers_url":"https://api.github.com/users/anparker/followers","following_url":"https://api.github.com/users/anparker/following{/other_user}","gists_url":"https://api.github.com/users/anparker/gists{/gist_id}","starred_url":"https://api.github.com/users/anparker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anparker/subscriptions","organizations_url":"https://api.github.com/users/anparker/orgs","repos_url":"https://api.github.com/users/anparker/repos","events_url":"https://api.github.com/users/anparker/events{/privacy}","received_events_url":"https://api.github.com/users/anparker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anparker/mojo-redis2","description":"Pure-Perl non-blocking I/O Redis driver","fork":true,"url":"https://api.github.com/repos/anparker/mojo-redis2","forks_url":"https://api.github.com/repos/anparker/mojo-redis2/forks","keys_url":"https://api.github.com/repos/anparker/mojo-redis2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anparker/mojo-redis2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anparker/mojo-redis2/teams","hooks_url":"https://api.github.com/repos/anparker/mojo-redis2/hooks","issue_events_url":"https://api.github.com/repos/anparker/mojo-redis2/issues/events{/number}","events_url":"https://api.github.com/repos/anparker/mojo-redis2/events","assignees_url":"https://api.github.com/repos/anparker/mojo-redis2/assignees{/user}","branches_url":"https://api.github.com/repos/anparker/mojo-redis2/branches{/branch}","tags_url":"https://api.github.com/repos/anparker/mojo-redis2/tags","blobs_url":"https://api.github.com/repos/anparker/mojo-redis2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anparker/mojo-redis2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anparker/mojo-redis2/git/refs{/sha}","trees_url":"https://api.github.com/repos/anparker/mojo-redis2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anparker/mojo-redis2/statuses/{sha}","languages_url":"https://api.github.com/repos/anparker/mojo-redis2/languages","stargazers_url":"https://api.github.com/repos/anparker/mojo-redis2/stargazers","contributors_url":"https://api.github.com/repos/anparker/mojo-redis2/contributors","subscribers_url":"https://api.github.com/repos/anparker/mojo-redis2/subscribers","subscription_url":"https://api.github.com/repos/anparker/mojo-redis2/subscription","commits_url":"https://api.github.com/repos/anparker/mojo-redis2/commits{/sha}","git_commits_url":"https://api.github.com/repos/anparker/mojo-redis2/git/commits{/sha}","comments_url":"https://api.github.com/repos/anparker/mojo-redis2/comments{/number}","issue_comment_url":"https://api.github.com/repos/anparker/mojo-redis2/issues/comments{/number}","contents_url":"https://api.github.com/repos/anparker/mojo-redis2/contents/{+path}","compare_url":"https://api.github.com/repos/anparker/mojo-redis2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anparker/mojo-redis2/merges","archive_url":"https://api.github.com/repos/anparker/mojo-redis2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anparker/mojo-redis2/downloads","issues_url":"https://api.github.com/repos/anparker/mojo-redis2/issues{/number}","pulls_url":"https://api.github.com/repos/anparker/mojo-redis2/pulls{/number}","milestones_url":"https://api.github.com/repos/anparker/mojo-redis2/milestones{/number}","notifications_url":"https://api.github.com/repos/anparker/mojo-redis2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anparker/mojo-redis2/labels{/name}","releases_url":"https://api.github.com/repos/anparker/mojo-redis2/releases{/id}","deployments_url":"https://api.github.com/repos/anparker/mojo-redis2/deployments","created_at":"2016-05-27T10:49:52Z","updated_at":"2016-05-27T10:49:53Z","pushed_at":"2016-06-03T08:05:13Z","git_url":"git://github.com/anparker/mojo-redis2.git","ssh_url":"git@github.com:anparker/mojo-redis2.git","clone_url":"https://github.com/anparker/mojo-redis2.git","svn_url":"https://github.com/anparker/mojo-redis2","homepage":null,"size":318,"stargazers_count":0,"watchers_count":0,"language":"Perl","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jhthorsen:master","ref":"master","sha":"1abd2e08833350961a72ff11f0da3c021354fbff","user":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"repo":{"id":22631821,"name":"mojo-redis2","full_name":"jhthorsen/mojo-redis2","owner":{"login":"jhthorsen","id":45729,"avatar_url":"https://avatars.githubusercontent.com/u/45729?v=3","gravatar_id":"","url":"https://api.github.com/users/jhthorsen","html_url":"https://github.com/jhthorsen","followers_url":"https://api.github.com/users/jhthorsen/followers","following_url":"https://api.github.com/users/jhthorsen/following{/other_user}","gists_url":"https://api.github.com/users/jhthorsen/gists{/gist_id}","starred_url":"https://api.github.com/users/jhthorsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhthorsen/subscriptions","organizations_url":"https://api.github.com/users/jhthorsen/orgs","repos_url":"https://api.github.com/users/jhthorsen/repos","events_url":"https://api.github.com/users/jhthorsen/events{/privacy}","received_events_url":"https://api.github.com/users/jhthorsen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jhthorsen/mojo-redis2","description":"Pure-Perl non-blocking I/O Redis driver","fork":false,"url":"https://api.github.com/repos/jhthorsen/mojo-redis2","forks_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/forks","keys_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/teams","hooks_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/hooks","issue_events_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/events{/number}","events_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/events","assignees_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/assignees{/user}","branches_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/branches{/branch}","tags_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/tags","blobs_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/statuses/{sha}","languages_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/languages","stargazers_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/stargazers","contributors_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/contributors","subscribers_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/subscribers","subscription_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/subscription","commits_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/comments{/number}","contents_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/contents/{+path}","compare_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/merges","archive_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/downloads","issues_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues{/number}","pulls_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls{/number}","milestones_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/milestones{/number}","notifications_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/labels{/name}","releases_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/releases{/id}","deployments_url":"https://api.github.com/repos/jhthorsen/mojo-redis2/deployments","created_at":"2014-08-05T05:39:53Z","updated_at":"2016-04-25T08:40:53Z","pushed_at":"2016-06-03T08:05:14Z","git_url":"git://github.com/jhthorsen/mojo-redis2.git","ssh_url":"git@github.com:jhthorsen/mojo-redis2.git","clone_url":"https://github.com/jhthorsen/mojo-redis2.git","svn_url":"https://github.com/jhthorsen/mojo-redis2","homepage":null,"size":328,"stargazers_count":8,"watchers_count":8,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":3,"forks":8,"open_issues":3,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18"},"html":{"href":"https://github.com/jhthorsen/mojo-redis2/pull/18"},"issue":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/18"},"comments":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/jhthorsen/mojo-redis2/statuses/ce776de7eb5ba362ef2132591e333078128cbad6"}}}}
{"actor":{"display_login":"jhthorsen"}}