vibed - best approach to manage central state (cached records)
Rikki Cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 11 19:54:24 PDT 2015
On 12/04/2015 7:24 a.m., Laeeth Isharc wrote:
> 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.
The caches I use in e.g. web service frameworks use __gshared. As long
as they are readonly most of the time, and written in one go. I see no
problems threading wise.
More information about the Digitalmars-d-learn
mailing list