vibed - best approach to manage central state (cached records)

Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 11 12:24:21 PDT 2015


Hi.

Two questions:

1. On startup I load various indexes from file storage into 
memory in the shared static this segment, and I would like to 
access these from threads serving web requests.  The data can be 
considered immutable once loaded.

What is the best way to make this data accessible?  Obviously 
static doesn't work as the threads have their own storage (I 
think this is what is happening).  __gshared works, but is there 
a better approach?


2. This works:
	auto router = new URLRouter;
	router.get("/pricebars",&renderPricebars);
	router.get("/names",&renderTickernames);
	router.registerRestInterface(new MarketDataAPIImplementation);
	auto settings = new HTTPServerSettings;
	settings.options=HTTPServerOption.parseQueryString;
	settings.port = 8080;
	listenHTTP(settings, router);

But if I switch the REST registration and the static route 
registration ("/pricebars" and "/names") then it segfaults.  
Reason for mixing regular routes and REST is to be able to serve 
some data in CSV form.

Thanks.


More information about the Digitalmars-d-learn mailing list