java - I need to fill the cache(CacheBuilder) as it starts. Is there any random way to do it? -
i have batch program uses cache. cache empty, data arrives compares received data previous received data.
* - if data not found: added data
* - if data found different: update data
* - if data found same: data filtered out
so, after few time, cache size increases data keep on increasing. , there processing taking quite amount of time process.
i need test whole situation, , have few incoming data , need regenerate situation. need fill cache starts. there random way it?
i using cachebuilder cache:
private cache> statescache = .newbuilder() .maximumsize(1000) .build();
i thought, there inbuilt function that. later did using loop:
private static cache> statescache = cachebuilder.newbuilder()// .maximumsize(1000).expireafteraccess(24, timeunit.hours).build();
static { (int = 0; < 999; i++) { map<string, state> map = new hashmap<string, state>(); (int j = 0; j < 50; j++) { state randomstate = new state() { string value = null; string id = null; string data = null; @override public void setvalue(string value) { this.value = value; } @override public void setid(string id) { this.id = id; } @override public void setdata(string data) { this.data = data; } @override public string getvalue() { return value; } @override public string getid() { return id; } @override public string getdata() { return data; } }; randomstate.setdata("data_" + j); randomstate.setid("id_" + j); randomstate.setvalue("value_" + j); map.put("id_" + j, randomstate); } statescache.put("bstn_" + string.format("%04d", i), map); } }
Comments
Post a Comment