{"id":20572028,"url":"https://github.com/netease/pomelo-sync","last_synced_at":"2025-10-24T08:52:50.720Z","repository":{"id":4400227,"uuid":"5537398","full_name":"NetEase/pomelo-sync","owner":"NetEase","description":"the backend database sync module","archived":false,"fork":false,"pushed_at":"2013-12-13T09:39:50.000Z","size":212,"stargazers_count":40,"open_issues_count":0,"forks_count":21,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-21T18:01:14.771Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NetEase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-24T07:57:54.000Z","updated_at":"2025-04-09T14:24:50.000Z","dependencies_parsed_at":"2022-08-29T16:51:21.418Z","dependency_job_id":null,"html_url":"https://github.com/NetEase/pomelo-sync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NetEase/pomelo-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetEase","download_url":"https://codeload.github.com/NetEase/pomelo-sync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetEase%2Fpomelo-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280768915,"owners_count":26387533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T05:18:05.148Z","updated_at":"2025-10-24T08:52:50.694Z","avatar_url":"https://github.com/NetEase.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#data-sync\ndata sync module is simple sync memory data into store engine like mysql,redis,file.\n\nAs we known, updating data is very frequently in game application. Especial in MMORPG kind game. User game data,such as location,flood,equipment,etc. almost always change as time going. For the purpose of avoid such update action cost, we decide to keep a copy data in memory. And keep synchronized with a timer and log;\n\nData sync can support both timer call and instance invoke for the different\nsituation. Most of time the developer don't pay attention to it;\n\nData sync also can support memory operation like NOSQL database such as\nredis,mongodb etc. most of time developer can seem as a memory database without\ntransaction.\n\nData sync features include timer sync,set,get,mset,mget,hset,hget,incr,decr,flush,merger,showdown,info,etc. and the developer can extend it very easily.\n\n##Installation\n```\nnpm install pomelo-sync\n```\n\n##Usage\n``` javascript\n\nvar opt = opt || {};\n\nvar updateUser = function(dbclient,val) {\n    console.log('mock save %j',val);\n}\n\nvar dbclient = {};//db connection etc;\nvar id = 10001;\nvar optKey = 'updateUser';\nvar mapping = {}; //key function mapping \nmapping[optKey]=updateUser;\nopt.mapping = mapping;\nopt.client = dbclient;\nopt.interval = 2000;\n\nvar Sync = require('pomelo-sync');\nvar sync = new Sync(opt) ;\nsync.exec(optKey,id,{name:'hello'});\n\n``` \n\n##API\n###sync.exec(key,id,val,cb)\nAdd a object to sync for timer exec call back. \n####Arguments\n+ key - the key function mapping for wanted to call back,it must be unique.\n+ id - object primary key for merger operation. \n+ val -  the object wanted to synchronized. \n+ cb - the function call back when timer exec.\n\n###sync.flush(key,id,val,cb)\nimmediately synchronized the memory data with out waiting timer and will remove\nwaiting queue data;\n####Arguments\n+ key - the key function mapping for wanted to call back,it must be unique.\n+ id - object primary key for merger operation. \n+ val -  the object wanted to synchronized. \n+ cb - the function call back when timer exec.\n\n###sync.isDone\nget the db sync status when the queue is empty,it should return true;otherwise\nreturn false;\n\n  \n\n##Notice \nsystem default sync time is 1000 * 60,\nif you use mysql or redis sync,you should set options.client,the file sync is default but it doesn't load in current.\nMysql OR mapping in this modules do not support,user should realize it self.\n\n##ADD\nfor more usage detail , reading source and benchmark and test case from\nsource is recommended;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetease%2Fpomelo-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetease%2Fpomelo-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetease%2Fpomelo-sync/lists"}