带有nodejs的mongodb(npm mongodb)(mongodb with nodejs(npm mongodb))
在我的应用程序中,我必须使用nodejs(npm mongodb)将数据存储到mongodb。 我已经安装了mongodb,nodejs和npm mongodb但这里的问题是我将它们安装在不同的文件夹中。 我无法正确组织目录结构,这是我收到错误的方式。如果你告诉我文件夹结构,它将帮助我很多。
提前致谢
In my application i have to store data to mongodb using nodejs(npm mongodb). I have installed mongodb , nodejs and npm mongodb but the problem here is I installed them in separate folders. I am unable to organize the directory structure properly that's way I am getting errors.If you tell me the folder structure it will help me a lot.
Thanks in advance
原文:https://stackoverflow.com/questions/15332042
最满意答案
另一种方法是在代码周围使用信号量来检索池中的连接(并希望返回它们)。 一个sempahore就像一个锁定语句,除了一次允许可配置数量的请求者,而不仅仅是一个。
像这样的东西应该这样做:
//Assuming mySemaphore is a semaphore instance, e.g. // public static Semaphore mySemaphore = new Semaphore(100,100); try { mySemaphore.WaitOne(); // This will block until a slot is available. DosomeDatabaseLogic(); } finally { mySemaphore.Release(); }
Another approach is to use a semaphore around the code that retrieves connections from the pool (and, hopefully, returns them). A sempahore is like a lock statement, except that it allows a configurable number of requestors at a time, not just one.
Something like this should do:
//Assuming mySemaphore is a semaphore instance, e.g. // public static Semaphore mySemaphore = new Semaphore(100,100); try { mySemaphore.WaitOne(); // This will block until a slot is available. DosomeDatabaseLogic(); } finally { mySemaphore.Release(); }