简体   繁体   English

没有db或filesystem的java公共存储选项

[英]java common storage options without db or filesystem

I am designing a banking web application where i want to store some common data shared among users/sessions. 我正在设计一个银行Web应用程序,我想存储一些在用户/会话之间共享的公共数据。 I want to persist the data but don't have any options for using database or file system. 我想保留数据,但没有任何使用数据库或文件系统的选项。 Requirement is whenever common data is modified it should be visible to all instantaneously.I would appreciate some suggestions. 要求是每当公共数据被修改时,它应该立即可见。我将很感激一些建议。

Try to use POJO . 尝试使用POJO Then store all your POJO in a List or a Map. 然后将所有POJO存储在列表或地图中。

eg 例如

//this is your pojo
public class User{
     private String name;
     private int age;

     public void setName(String name){
           this.name = name;
     }

     public String getName(){
           return this.name;
     }

     public void setAge(int age){
           this.age = age;
     }

     public int getAge(){
           return this.age;
     }
}


public class TestUser{

     public static void main(String args[]){
           //to populate record, create object user
           User user1 = new User();
           user1.setName = "name1";
           user1.setAge = "20";//then so on

           //after creating object, store it in a <a href="http://tutorials.jenkov.com/java-collections/index.html"collection</a>. Depends on what you want.
           List<User> myList = new ArrayList<User>();
           //then add it to your collection
           myList.add(user1); //and so on
           //you can access now your record on your list
     }
}

您可以使用hsql db jdbc驱动程序,该驱动程序支持为内存数据库支持创建内存数据库checkout hsql db文档

I would suggest you to use Caches (Oracle Coherence , simple Map) there are many option available. 我建议你使用Caches (Oracle Coherence,简单Map)有很多选项可供选择。 If you want to persist the data for permanently then i don't thing any other option than Database/Filesystem . 如果你想永久保存数据那么我没有任何其他选项而不是Database/Filesystem

Caching 高速缓存

You can use cache like Memcached. 您可以像Memcached一样使用缓存。

or you can use in-memory database like HSqlDB. 或者你可以使用像HSqlDB这样的内存数据库。

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

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