简体   繁体   English

如何将整个SQLite文件放入ASP.NET的缓存中?

[英]How to put a whole SQLite file in cache in ASP.NET?

Noob needs help) I'm having a trouble with caching an SQLite database in ASP.NET MVC 4. All I need is to create a temporary copy of DB.db file and use it within a session and delete it when the session is over. Noob需要帮助)我在ASP.NET MVC 4中缓存SQLite数据库时遇到了麻烦。我需要创建的是DB.db文件的临时副本,并在会话中使用它,并在会话结束时删除它。 。 Without doing it one session can crash another while using the same databse file. 如果不这样做,则在使用相同的数据库文件时,一个会话可能会使另一个会话崩溃。 Of course I could do something like 我当然可以做类似的事情

Cache["Database"] = //Some code transfering DB.db content to cache

but there must be some way to copy it for a while. 但是必须有某种方式可以复制一段时间。 File.Copy() and File.Delete() doesn't fit. File.Copy()File.Delete()不适合。

PS> Sorry, I'm completely bumb in using databases. PS>抱歉,我完全不喜欢使用数据库。 On my way to exploring entity fw) 在探索实体的途中(fw)

You can create sqlite databases in memory, then I guess you could add that sqlite db to a session. 您可以在内存中创建sqlite数据库,然后我猜您可以将该sqlite数据库添加到会话中。 This seems like a real bad practice though. 不过,这似乎是一种真正的坏习惯。 I'd rethink what you are trying to do. 我会重新考虑您要做什么。 If you proceed this way google sqlite db memory...I think I remember you just add something on to the connection string to create the db in memory. 如果您以这种方式进行操作,我想我记得您只是在连接字符串上添加了一些内容以在内存中创建数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM