{"action":"created","comment":{"url":"https://api.github.com/repos/openchange/openchange/pulls/comments/26028276","id":26028276,"diff_hunk":"@@ -29,16 +30,302 @@\n #include \"libmapi/libmapi_private.h\"\n #include <mysql/mysql.h>\n #include \"../../util/mysql.h\"\n+#include \"../../util/ccan/hash/hash.h\"\n #include \"../../util/schema_migration.h\"\n #include \"mapiproxy/libmapiproxy/backends/openchangedb_mysql.h\"\n \n #include <talloc.h>\n-\n+#include <libmemcached/memcached.h>\n \n #define MYSQL(context)\t((MYSQL *)context->data)\n \n \n /**\n+   \\details Generate key for FMID cache\n+\n+   \\param mem_ctx pointer to the memory context\n+   \\param uri pointer to the uri to use for hashing\n+\n+   \\return String allocated with TALLOC on success, otherwise NULL\n+ */\n+static char *_memcached_gen_key(TALLOC_CTX *mem_ctx, const char *uri)\n+{\n+\treturn talloc_asprintf(mem_ctx, \"%\"PRIx64, hash64_any((void *)uri, strlen(uri), 0));\n+}\n+\n+\n+/**\n+   \\details Generate value for FMID cache\n+\n+   \\param mem_ctx pointer to the memory context\n+   \\param fmid the fmid to convert\n+\n+   \\return String allocated with TALLOC on success, otherwise NULL\n+ */\n+static char *_memcached_gen_value(TALLOC_CTX *mem_ctx, uint64_t fmid)\n+{\n+\treturn talloc_asprintf(mem_ctx, \"%\"PRIu64, fmid);\n+}\n+\n+\n+/**\n+   \\details Prepare FMID cache for specified user\n+\n+   \\param ictx valid pointer to the indexing context\n+   \\param conn_str connection string to memcached server\n+   \\param username name of the user for to create the FMID cache for\n+\n+   \\note Fallback to 127.0.0.1:11211 if server_string is missing\n+\n+   \\return valid memcached_st pointer on success, otherwise NULL\n+ */\n+static memcached_st *_memcached_setup(struct indexing_context *ictx,\n+\t\t\t\t      const char *conn_str,\n+\t\t\t\t      const char *username)\n+{\n+\tTALLOC_CTX\t\t*mem_ctx;\n+\tchar\t\t\t*sql;\n+\tint\t\t\tmret;\n+\tMYSQL_RES\t\t*res;\n+\tuint32_t\t\tnum_rows = 0;\n+\tmemcached_server_st\t*servers = NULL;\n+\tmemcached_st\t\t*memc = NULL;\n+\tmemcached_return\trc;\n+\tuint32_t\t\ti;\n+\n+\tDEBUG(5, (\"[INFO] _memcached_setup for '%s'\\n\", username));","path":"mapiproxy/libmapistore/backends/indexing_mysql.c","position":76,"original_position":76,"commit_id":"8a33a6cae7e1339ad63ccf5e85c70c81f93c19d9","original_commit_id":"8a33a6cae7e1339ad63ccf5e85c70c81f93c19d9","user":{"login":"jkerihuel","id":3603061,"avatar_url":"https://avatars.githubusercontent.com/u/3603061?v=3","gravatar_id":"","url":"https://api.github.com/users/jkerihuel","html_url":"https://github.com/jkerihuel","followers_url":"https://api.github.com/users/jkerihuel/followers","following_url":"https://api.github.com/users/jkerihuel/following{/other_user}","gists_url":"https://api.github.com/users/jkerihuel/gists{/gist_id}","starred_url":"https://api.github.com/users/jkerihuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkerihuel/subscriptions","organizations_url":"https://api.github.com/users/jkerihuel/orgs","repos_url":"https://api.github.com/users/jkerihuel/repos","events_url":"https://api.github.com/users/jkerihuel/events{/privacy}","received_events_url":"https://api.github.com/users/jkerihuel/received_events","type":"User","site_admin":false},"body":":+1: but :chicken: / :egg: issue - TBD when logging API is merged.","created_at":"2015-03-09T11:27:23Z","updated_at":"2015-03-09T11:27:23Z","html_url":"https://github.com/openchange/openchange/pull/224#discussion_r26028276","pull_request_url":"https://api.github.com/repos/openchange/openchange/pulls/224","_links":{"self":{"href":"https://api.github.com/repos/openchange/openchange/pulls/comments/26028276"},"html":{"href":"https://github.com/openchange/openchange/pull/224#discussion_r26028276"},"pull_request":{"href":"https://api.github.com/repos/openchange/openchange/pulls/224"}}},"pull_request":{"url":"https://api.github.com/repos/openchange/openchange/pulls/224","id":30491111,"html_url":"https://github.com/openchange/openchange/pull/224","diff_url":"https://github.com/openchange/openchange/pull/224.diff","patch_url":"https://github.com/openchange/openchange/pull/224.patch","issue_url":"https://api.github.com/repos/openchange/openchange/issues/224","number":224,"state":"open","locked":false,"title":"mapistore: implement fmid cache with memcached","user":{"login":"jkerihuel","id":3603061,"avatar_url":"https://avatars.githubusercontent.com/u/3603061?v=3","gravatar_id":"","url":"https://api.github.com/users/jkerihuel","html_url":"https://github.com/jkerihuel","followers_url":"https://api.github.com/users/jkerihuel/followers","following_url":"https://api.github.com/users/jkerihuel/following{/other_user}","gists_url":"https://api.github.com/users/jkerihuel/gists{/gist_id}","starred_url":"https://api.github.com/users/jkerihuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkerihuel/subscriptions","organizations_url":"https://api.github.com/users/jkerihuel/orgs","repos_url":"https://api.github.com/users/jkerihuel/repos","events_url":"https://api.github.com/users/jkerihuel/events{/privacy}","received_events_url":"https://api.github.com/users/jkerihuel/received_events","type":"User","site_admin":false},"body":"Solve scalability and performance issue when importing business size mailbox","created_at":"2015-03-04T18:30:18Z","updated_at":"2015-03-09T11:27:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1392fcd34133e842cfbf0b1b80e314475f73c177","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openchange/openchange/pulls/224/commits","review_comments_url":"https://api.github.com/repos/openchange/openchange/pulls/224/comments","review_comment_url":"https://api.github.com/repos/openchange/openchange/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openchange/openchange/issues/224/comments","statuses_url":"https://api.github.com/repos/openchange/openchange/statuses/8a33a6cae7e1339ad63ccf5e85c70c81f93c19d9","head":{"label":"openchange:jkerihuel/fmid-cache","ref":"jkerihuel/fmid-cache","sha":"8a33a6cae7e1339ad63ccf5e85c70c81f93c19d9","user":{"login":"openchange","id":5413705,"avatar_url":"https://avatars.githubusercontent.com/u/5413705?v=3","gravatar_id":"","url":"https://api.github.com/users/openchange","html_url":"https://github.com/openchange","followers_url":"https://api.github.com/users/openchange/followers","following_url":"https://api.github.com/users/openchange/following{/other_user}","gists_url":"https://api.github.com/users/openchange/gists{/gist_id}","starred_url":"https://api.github.com/users/openchange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openchange/subscriptions","organizations_url":"https://api.github.com/users/openchange/orgs","repos_url":"https://api.github.com/users/openchange/repos","events_url":"https://api.github.com/users/openchange/events{/privacy}","received_events_url":"https://api.github.com/users/openchange/received_events","type":"Organization","site_admin":false},"repo":{"id":12688822,"name":"openchange","full_name":"openchange/openchange","owner":{"login":"openchange","id":5413705,"avatar_url":"https://avatars.githubusercontent.com/u/5413705?v=3","gravatar_id":"","url":"https://api.github.com/users/openchange","html_url":"https://github.com/openchange","followers_url":"https://api.github.com/users/openchange/followers","following_url":"https://api.github.com/users/openchange/following{/other_user}","gists_url":"https://api.github.com/users/openchange/gists{/gist_id}","starred_url":"https://api.github.com/users/openchange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openchange/subscriptions","organizations_url":"https://api.github.com/users/openchange/orgs","repos_url":"https://api.github.com/users/openchange/repos","events_url":"https://api.github.com/users/openchange/events{/privacy}","received_events_url":"https://api.github.com/users/openchange/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openchange/openchange","description":"OpenChange Project","fork":false,"url":"https://api.github.com/repos/openchange/openchange","forks_url":"https://api.github.com/repos/openchange/openchange/forks","keys_url":"https://api.github.com/repos/openchange/openchange/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openchange/openchange/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openchange/openchange/teams","hooks_url":"https://api.github.com/repos/openchange/openchange/hooks","issue_events_url":"https://api.github.com/repos/openchange/openchange/issues/events{/number}","events_url":"https://api.github.com/repos/openchange/openchange/events","assignees_url":"https://api.github.com/repos/openchange/openchange/assignees{/user}","branches_url":"https://api.github.com/repos/openchange/openchange/branches{/branch}","tags_url":"https://api.github.com/repos/openchange/openchange/tags","blobs_url":"https://api.github.com/repos/openchange/openchange/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openchange/openchange/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openchange/openchange/git/refs{/sha}","trees_url":"https://api.github.com/repos/openchange/openchange/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openchange/openchange/statuses/{sha}","languages_url":"https://api.github.com/repos/openchange/openchange/languages","stargazers_url":"https://api.github.com/repos/openchange/openchange/stargazers","contributors_url":"https://api.github.com/repos/openchange/openchange/contributors","subscribers_url":"https://api.github.com/repos/openchange/openchange/subscribers","subscription_url":"https://api.github.com/repos/openchange/openchange/subscription","commits_url":"https://api.github.com/repos/openchange/openchange/commits{/sha}","git_commits_url":"https://api.github.com/repos/openchange/openchange/git/commits{/sha}","comments_url":"https://api.github.com/repos/openchange/openchange/comments{/number}","issue_comment_url":"https://api.github.com/repos/openchange/openchange/issues/comments{/number}","contents_url":"https://api.github.com/repos/openchange/openchange/contents/{+path}","compare_url":"https://api.github.com/repos/openchange/openchange/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openchange/openchange/merges","archive_url":"https://api.github.com/repos/openchange/openchange/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openchange/openchange/downloads","issues_url":"https://api.github.com/repos/openchange/openchange/issues{/number}","pulls_url":"https://api.github.com/repos/openchange/openchange/pulls{/number}","milestones_url":"https://api.github.com/repos/openchange/openchange/milestones{/number}","notifications_url":"https://api.github.com/repos/openchange/openchange/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openchange/openchange/labels{/name}","releases_url":"https://api.github.com/repos/openchange/openchange/releases{/id}","created_at":"2013-09-08T22:39:00Z","updated_at":"2015-03-09T10:04:29Z","pushed_at":"2015-03-09T10:04:33Z","git_url":"git://github.com/openchange/openchange.git","ssh_url":"git@github.com:openchange/openchange.git","clone_url":"https://github.com/openchange/openchange.git","svn_url":"https://github.com/openchange/openchange","homepage":null,"size":24981,"stargazers_count":46,"watchers_count":46,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":20,"forks":28,"open_issues":20,"watchers":46,"default_branch":"master"}},"base":{"label":"openchange:master","ref":"master","sha":"5379de0c88a7cfa783bf3ab02763ba3a93066285","user":{"login":"openchange","id":5413705,"avatar_url":"https://avatars.githubusercontent.com/u/5413705?v=3","gravatar_id":"","url":"https://api.github.com/users/openchange","html_url":"https://github.com/openchange","followers_url":"https://api.github.com/users/openchange/followers","following_url":"https://api.github.com/users/openchange/following{/other_user}","gists_url":"https://api.github.com/users/openchange/gists{/gist_id}","starred_url":"https://api.github.com/users/openchange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openchange/subscriptions","organizations_url":"https://api.github.com/users/openchange/orgs","repos_url":"https://api.github.com/users/openchange/repos","events_url":"https://api.github.com/users/openchange/events{/privacy}","received_events_url":"https://api.github.com/users/openchange/received_events","type":"Organization","site_admin":false},"repo":{"id":12688822,"name":"openchange","full_name":"openchange/openchange","owner":{"login":"openchange","id":5413705,"avatar_url":"https://avatars.githubusercontent.com/u/5413705?v=3","gravatar_id":"","url":"https://api.github.com/users/openchange","html_url":"https://github.com/openchange","followers_url":"https://api.github.com/users/openchange/followers","following_url":"https://api.github.com/users/openchange/following{/other_user}","gists_url":"https://api.github.com/users/openchange/gists{/gist_id}","starred_url":"https://api.github.com/users/openchange/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openchange/subscriptions","organizations_url":"https://api.github.com/users/openchange/orgs","repos_url":"https://api.github.com/users/openchange/repos","events_url":"https://api.github.com/users/openchange/events{/privacy}","received_events_url":"https://api.github.com/users/openchange/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openchange/openchange","description":"OpenChange Project","fork":false,"url":"https://api.github.com/repos/openchange/openchange","forks_url":"https://api.github.com/repos/openchange/openchange/forks","keys_url":"https://api.github.com/repos/openchange/openchange/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openchange/openchange/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openchange/openchange/teams","hooks_url":"https://api.github.com/repos/openchange/openchange/hooks","issue_events_url":"https://api.github.com/repos/openchange/openchange/issues/events{/number}","events_url":"https://api.github.com/repos/openchange/openchange/events","assignees_url":"https://api.github.com/repos/openchange/openchange/assignees{/user}","branches_url":"https://api.github.com/repos/openchange/openchange/branches{/branch}","tags_url":"https://api.github.com/repos/openchange/openchange/tags","blobs_url":"https://api.github.com/repos/openchange/openchange/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openchange/openchange/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openchange/openchange/git/refs{/sha}","trees_url":"https://api.github.com/repos/openchange/openchange/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openchange/openchange/statuses/{sha}","languages_url":"https://api.github.com/repos/openchange/openchange/languages","stargazers_url":"https://api.github.com/repos/openchange/openchange/stargazers","contributors_url":"https://api.github.com/repos/openchange/openchange/contributors","subscribers_url":"https://api.github.com/repos/openchange/openchange/subscribers","subscription_url":"https://api.github.com/repos/openchange/openchange/subscription","commits_url":"https://api.github.com/repos/openchange/openchange/commits{/sha}","git_commits_url":"https://api.github.com/repos/openchange/openchange/git/commits{/sha}","comments_url":"https://api.github.com/repos/openchange/openchange/comments{/number}","issue_comment_url":"https://api.github.com/repos/openchange/openchange/issues/comments{/number}","contents_url":"https://api.github.com/repos/openchange/openchange/contents/{+path}","compare_url":"https://api.github.com/repos/openchange/openchange/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openchange/openchange/merges","archive_url":"https://api.github.com/repos/openchange/openchange/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openchange/openchange/downloads","issues_url":"https://api.github.com/repos/openchange/openchange/issues{/number}","pulls_url":"https://api.github.com/repos/openchange/openchange/pulls{/number}","milestones_url":"https://api.github.com/repos/openchange/openchange/milestones{/number}","notifications_url":"https://api.github.com/repos/openchange/openchange/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openchange/openchange/labels{/name}","releases_url":"https://api.github.com/repos/openchange/openchange/releases{/id}","created_at":"2013-09-08T22:39:00Z","updated_at":"2015-03-09T10:04:29Z","pushed_at":"2015-03-09T10:04:33Z","git_url":"git://github.com/openchange/openchange.git","ssh_url":"git@github.com:openchange/openchange.git","clone_url":"https://github.com/openchange/openchange.git","svn_url":"https://github.com/openchange/openchange","homepage":null,"size":24981,"stargazers_count":46,"watchers_count":46,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":20,"forks":28,"open_issues":20,"watchers":46,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openchange/openchange/pulls/224"},"html":{"href":"https://github.com/openchange/openchange/pull/224"},"issue":{"href":"https://api.github.com/repos/openchange/openchange/issues/224"},"comments":{"href":"https://api.github.com/repos/openchange/openchange/issues/224/comments"},"review_comments":{"href":"https://api.github.com/repos/openchange/openchange/pulls/224/comments"},"review_comment":{"href":"https://api.github.com/repos/openchange/openchange/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openchange/openchange/pulls/224/commits"},"statuses":{"href":"https://api.github.com/repos/openchange/openchange/statuses/8a33a6cae7e1339ad63ccf5e85c70c81f93c19d9"}}}}