You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ravi Puri <ra...@gmail.com> on 2016/08/11 07:04:58 UTC

Clear the cached data?

I want to clear all the data cached in server and client nodes. So how to do
it as i have to do it another class.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Clear the cached data?

Posted by vkulichenko <va...@gmail.com>.
Ravi,

If you want to reuse the existing client, you can use the Ignition.ignite()
method. Is this what you're looking for?

Regarding the difference between clear() and destroy(): the former iterates
through cache, so it is generally much slower than destroy().

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946p6991.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Clear the cached data?

Posted by Ravi kumar Puri <ra...@gmail.com>.
I will use clear or destroy method.. but in order to invoke that methods i
need ignite object from the server or client loaded classes as i have to
implement that in other class... In order to use in another i need to
create a new instance for ignite and intialise it null. That means i didnt
get any reference from server or clientloaded classes ignite object.
Undeestand?

Suppose

Class A()
Ignite ignite=Ignition.start("ignite-cfg.xml");
Then i create a cache name with this ignite object.

Class B()
In this class i want to use above class ignite object in order to clear the
cache.

So how to use it in class B() so that watever nodes loaded and data cached
in classA() cna be cleared from the scratch??

Understood??
On 11-Aug-2016 15:38, "Alisher Alimov" <al...@gmail.com> wrote:

> All 2 methods clear cache entries, but also IgniteCache#destroy delete
> cache meta info from all nodes and theoretically IgniteCache#clear will be
> faster to clean cache
>
> With best regards
> Alisher Alimov
> alimovalisher@gmail.com
>
>
>
>
> On 11 авг. 2016 г., at 12:53, Alexey Kuznetsov <ak...@gridgain.com>
> wrote:
>
> Alisher, Ravi.
>
> cache.clear() could take a lot of time in case of large grid / many
> entries.
>
> Will cache.destroy() + ignite.getOrCreateCache(ccfg) - faster?
>
> On Thu, Aug 11, 2016 at 4:39 PM, Alisher Alimov <al...@gmail.com>
> wrote:
>
>> Hi!
>>
>> IgniteCache#close doesn’t clear data by contract for non local caches
>>
>> /**
>>  * Closes this cache instance.
>>  * <p>
>>  * For local cache equivalent to {@link #destroy()}.
>>  * For distributed caches, if called on clients, stops client cache, if called on a server node,
>>  * just closes this cache instance and does not destroy cache data.
>>  * <p>
>>  * After cache instance is closed another {@link IgniteCache} instance for the same
>>  * cache can be created using {@link Ignite#cache(String)} method.
>>  */
>>
>> To clear cache data you must invoke IgniteCache#clear() it’s will clear
>> cache contents
>>
>> Ignite doesn’t have method to clean data in all cache, but you can use
>>
>> Ignite#cacheNames(cacheName -> Ignite#cache(cacheName).clear())
>>
>> With best regards
>> Alisher Alimov
>> alimovalisher@gmail.com
>>
>>
>>
>>
>> On 11 авг. 2016 г., at 10:14, Alexey Kuznetsov <ak...@gridgain.com>
>> wrote:
>>
>> Hi, Ravi.
>>
>> You may close all caches and recreate them (from code).
>> Will this work in your case?
>>
>> On Thu, Aug 11, 2016 at 2:04 PM, Ravi Puri <ra...@gmail.com>
>> wrote:
>>
>>> I want to clear all the data cached in server and client nodes. So how
>>> to do
>>> it as i have to do it another class.
>>>
>>>
>>>
>>> --
>>> View this message in context: http://apache-ignite-users.705
>>> 18.x6.nabble.com/Clear-the-cached-data-tp6946.html
>>> Sent from the Apache Ignite Users mailing list archive at Nabble.com
>>> <http://nabble.com/>.
>>>
>>
>>
>>
>> --
>> Alexey Kuznetsov
>> GridGain Systems
>> www.gridgain.com
>>
>>
>>
>
>
> --
> Alexey Kuznetsov
> GridGain Systems
> www.gridgain.com
>
>
>

Re: Clear the cached data?

Posted by Alisher Alimov <al...@gmail.com>.
All 2 methods clear cache entries, but also IgniteCache#destroy delete cache meta info from all nodes and theoretically IgniteCache#clear will be faster to clean cache

With best regards
Alisher Alimov
alimovalisher@gmail.com




> On 11 авг. 2016 г., at 12:53, Alexey Kuznetsov <ak...@gridgain.com> wrote:
> 
> Alisher, Ravi.
> 
> cache.clear() could take a lot of time in case of large grid / many entries.
> 
> Will cache.destroy() + ignite.getOrCreateCache(ccfg) - faster?
> 
> On Thu, Aug 11, 2016 at 4:39 PM, Alisher Alimov <alimovalisher@gmail.com <ma...@gmail.com>> wrote:
> Hi!
> 
> IgniteCache#close doesn’t clear data by contract for non local caches
> 
> /**
>  * Closes this cache instance.
>  * <p>
>  * For local cache equivalent to {@link #destroy()}.
>  * For distributed caches, if called on clients, stops client cache, if called on a server node,
>  * just closes this cache instance and does not destroy cache data.
>  * <p>
>  * After cache instance is closed another {@link IgniteCache} instance for the same
>  * cache can be created using {@link Ignite#cache(String)} method.
>  */
> To clear cache data you must invoke IgniteCache#clear() it’s will clear cache contents
> 
> Ignite doesn’t have method to clean data in all cache, but you can use
> 
> Ignite#cacheNames(cacheName -> Ignite#cache(cacheName).clear())
> 
> With best regards
> Alisher Alimov
> alimovalisher@gmail.com <ma...@gmail.com>
> 
> 
> 
> 
>> On 11 авг. 2016 г., at 10:14, Alexey Kuznetsov <akuznetsov@gridgain.com <ma...@gridgain.com>> wrote:
>> 
>> Hi, Ravi.
>> 
>> You may close all caches and recreate them (from code).
>> Will this work in your case?
>> 
>> On Thu, Aug 11, 2016 at 2:04 PM, Ravi Puri <ravikumarpuri04@gmail.com <ma...@gmail.com>> wrote:
>> I want to clear all the data cached in server and client nodes. So how to do
>> it as i have to do it another class.
>> 
>> 
>> 
>> --
>> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946.html <http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946.html>
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com <http://nabble.com/>.
>> 
>> 
>> 
>> --
>> Alexey Kuznetsov
>> GridGain Systems
>> www.gridgain.com <http://www.gridgain.com/>
> 
> 
> 
> 
> --
> Alexey Kuznetsov
> GridGain Systems
> www.gridgain.com <http://www.gridgain.com/>


Re: Clear the cached data?

Posted by Alexey Kuznetsov <ak...@gridgain.com>.
Alisher, Ravi.

cache.clear() could take a lot of time in case of large grid / many entries.

Will cache.destroy() + ignite.getOrCreateCache(ccfg) - faster?

On Thu, Aug 11, 2016 at 4:39 PM, Alisher Alimov <al...@gmail.com>
wrote:

> Hi!
>
> IgniteCache#close doesn’t clear data by contract for non local caches
>
> /**
>  * Closes this cache instance.
>  * <p>
>  * For local cache equivalent to {@link #destroy()}.
>  * For distributed caches, if called on clients, stops client cache, if called on a server node,
>  * just closes this cache instance and does not destroy cache data.
>  * <p>
>  * After cache instance is closed another {@link IgniteCache} instance for the same
>  * cache can be created using {@link Ignite#cache(String)} method.
>  */
>
> To clear cache data you must invoke IgniteCache#clear() it’s will clear
> cache contents
>
> Ignite doesn’t have method to clean data in all cache, but you can use
>
> Ignite#cacheNames(cacheName -> Ignite#cache(cacheName).clear())
>
> With best regards
> Alisher Alimov
> alimovalisher@gmail.com
>
>
>
>
> On 11 авг. 2016 г., at 10:14, Alexey Kuznetsov <ak...@gridgain.com>
> wrote:
>
> Hi, Ravi.
>
> You may close all caches and recreate them (from code).
> Will this work in your case?
>
> On Thu, Aug 11, 2016 at 2:04 PM, Ravi Puri <ra...@gmail.com>
> wrote:
>
>> I want to clear all the data cached in server and client nodes. So how to
>> do
>> it as i have to do it another class.
>>
>>
>>
>> --
>> View this message in context: http://apache-ignite-users.705
>> 18.x6.nabble.com/Clear-the-cached-data-tp6946.html
>> Sent from the Apache Ignite Users mailing list archive at Nabble.com
>> <http://nabble.com>.
>>
>
>
>
> --
> Alexey Kuznetsov
> GridGain Systems
> www.gridgain.com
>
>
>


-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com

Re: Clear the cached data?

Posted by Alisher Alimov <al...@gmail.com>.
Hi!

IgniteCache#close doesn’t clear data by contract for non local caches

/**
 * Closes this cache instance.
 * <p>
 * For local cache equivalent to {@link #destroy()}.
 * For distributed caches, if called on clients, stops client cache, if called on a server node,
 * just closes this cache instance and does not destroy cache data.
 * <p>
 * After cache instance is closed another {@link IgniteCache} instance for the same
 * cache can be created using {@link Ignite#cache(String)} method.
 */
To clear cache data you must invoke IgniteCache#clear() it’s will clear cache contents

Ignite doesn’t have method to clean data in all cache, but you can use

Ignite#cacheNames(cacheName -> Ignite#cache(cacheName).clear())

With best regards
Alisher Alimov
alimovalisher@gmail.com




> On 11 авг. 2016 г., at 10:14, Alexey Kuznetsov <ak...@gridgain.com> wrote:
> 
> Hi, Ravi.
> 
> You may close all caches and recreate them (from code).
> Will this work in your case?
> 
> On Thu, Aug 11, 2016 at 2:04 PM, Ravi Puri <ravikumarpuri04@gmail.com <ma...@gmail.com>> wrote:
> I want to clear all the data cached in server and client nodes. So how to do
> it as i have to do it another class.
> 
> 
> 
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946.html <http://apache-ignite-users.70518.x6.nabble.com/Clear-the-cached-data-tp6946.html>
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
> 
> 
> 
> --
> Alexey Kuznetsov
> GridGain Systems
> www.gridgain.com <http://www.gridgain.com/>


Re: Clear the cached data?

Posted by Alexey Kuznetsov <ak...@gridgain.com>.
Hi, Ravi.

You may close all caches and recreate them (from code).
Will this work in your case?

On Thu, Aug 11, 2016 at 2:04 PM, Ravi Puri <ra...@gmail.com>
wrote:

> I want to clear all the data cached in server and client nodes. So how to
> do
> it as i have to do it another class.
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Clear-the-cached-data-tp6946.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 
Alexey Kuznetsov
GridGain Systems
www.gridgain.com