But, in my transaction method:

    PersonKey key = new PersonKey(5);

        System.out.println();
        System.out.println(">>> Update salary and write-through to database
for person with ID: " + key.getId());

        try (Transaction tx = ignite.transactions().txStart()) {
            // Read-through from database.
            Person p = cache.get(key);

            System.out.println(">>> Loaded person from database: " + p);

            double salary = p.getSalary();

            // Raise salary by 20%.
            p.setSalary(salary * 1.2);

            // Write-through to database
            // and store in cache.
            cache.put(key, p);
            System.out.println("Key: " + key + " Value: " + p + " put in
cache");
            
            p.setSalary(salary * 2);
            cache.put(key,  p);
           
            System.out.println("Key: " + key + " Value: " + p + " put in
cache");
            
            
            
            
            new Thread(new Runnable() {
                public void run()
                {
                         {
                                System.out.println("Starting new thread...");
                                PersonKey k1 = new PersonKey(5);
                        try (Transaction tx = ignite.transactions().txStart())
{
                                
                                Person v1 = cache.get(k1);
                                System.out.println("The value for key = 5 is: " 
+
v1);
                        }
                     }
                }
            }).start();
            tx.commit();
        }

        System.out.println(">>> Updated person: " + cache.get(key));
    }

when I start the new thread and get the value of key 5, I get the new value
only, even before committing it? Why is this so?



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/How-to-perform-lazy-write-to-database-tp4002p4078.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to