Created
August 3, 2015 08:01
-
-
Save dg3feiko/ffaa56c3f9cb5493eb05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Number = require("./index"); | |
var DBS = require('@aftership/postmen-datastorage').dbs; | |
var RedisCache = require('@aftership/postmen-datastorage').adaptor.redis; | |
var Dynamodb = require('@aftership/postmen-datastorage').adaptor.dynamodb; | |
DBS.configStore("number", { | |
db: new Dynamodb({ | |
region: 'ap-northeast-1', | |
table_name: 'development_sandbox_numbers' | |
}), | |
config: { | |
"cache": { | |
is_cacheable_r: true, | |
is_cacheable_w: true | |
} | |
} | |
}) | |
var number_store = DBS.store('number'); | |
var Redis = require("ioredis"); | |
var redis = new Redis(); | |
var Warlock = require("@aftership/iowarlock"); | |
var warlock = require("bluebird").promisifyAll(Warlock(redis)); | |
var nm = new Number({ | |
store: number_store, | |
warlock: warlock, | |
redis: redis | |
}); | |
require("co")(function* () { | |
try { | |
let res; | |
// res = yield number_store.findByKeyAndRange({ | |
// query: { | |
// key: { | |
// pool: "foo" | |
// }, | |
// range: { | |
// from:"active", | |
// to:"inactive" | |
// } | |
// }, | |
// index: 'pool-state_created_at-index', | |
// order: 'asc', | |
// limit: 1 | |
// }); | |
// res = yield nm.addSlot("foo_pool", { | |
// "type": "range", | |
// "min": 1, | |
// "max": 5 | |
// }); | |
// res = yield nm.addSlot("bar_pool", { | |
// "type": "values", | |
// "data":["123","456"] | |
// }); | |
// res = yield nm.addSlot("my_pool", { | |
// "type": "values", | |
// "data": ["a","b","c","d","e"] | |
// }); | |
// while(res = yield nm.popANumber("my_pool")) | |
// { | |
// // console.log(res); | |
// } | |
// res = yield nm.listSlots("my_pool"); | |
// res = yield nm.removeASlot("f963044b-db67-4d73-b801-19b08e3a8ca0"); | |
console.time("pop"); | |
res = yield [nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo"),nm.popANumber("foo")]; | |
console.timeEnd("pop"); | |
console.log(res); | |
} catch (e) { | |
console.error(e); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment