You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ignite.apache.org by Ognen Duzlevski <og...@gmail.com> on 2015/04/20 19:02:26 UTC

Getting all the keys in a cache

Hello,

I am looking at the
https://ignite.incubator.apache.org/releases/1.0.0/javadoc/ page and I
cannot find a method to just get all the keys in a particular cache. All
the get() methods require a known key or a set of known keys. What if I
have one app that is filling up the cache and another one that is
inspecting the same cache periodically for key/value changes?

Thanks!

Re: Getting all the keys in a cache

Posted by Ognen Duzlevski <og...@gmail.com>.
Just to follow up on this in case anyone runs into this thread - in Scala
the proper way to override the onUpdated() java method is:

class MyListener[K,V] extends CacheEntryUpdatedListener[K,V] {
      def
onUpdated(events:java.lang.Iterable[javax.cache.event.CacheEntryEvent[_<:K,_<:V]])
{
        events.foreach(x => println(s"${x.getKey},${x.getValue}")) //
replace with whatever you want
      }
  }

Took me some time to get the correct signature going.

Then you feed this to setLocalListener like this: setLocalListener(new
MyListener[<whatever is key type>,<whatever is value type>)

I am not sure how much coverage of the Java API us in the Scala API - it
did not look like much to me. In addition, wrapping everything into scalar
{}  on the scala side did not seem terribly useful but maybe I am missing
something.

On Mon, Apr 20, 2015 at 12:08 PM, Ognen Duzlevski <ognen.duzlevski@gmail.com
> wrote:

> Nice, thanks!
>
> On Mon, Apr 20, 2015 at 12:06 PM, Valentin Kulichenko <
> valentin.kulichenko@gmail.com> wrote:
>
>> Ognen,
>>
>> You can use continuous queries for that:
>>
>> https://ignite.incubator.apache.org/releases/1.0.0/javadoc/org/apache/ignite/cache/query/ContinuousQuery.html
>>
>> On Mon, Apr 20, 2015 at 10:02 AM, Ognen Duzlevski <
>> ognen.duzlevski@gmail.com
>> > wrote:
>>
>> > Hello,
>> >
>> > I am looking at the
>> > https://ignite.incubator.apache.org/releases/1.0.0/javadoc/ page and I
>> > cannot find a method to just get all the keys in a particular cache. All
>> > the get() methods require a known key or a set of known keys. What if I
>> > have one app that is filling up the cache and another one that is
>> > inspecting the same cache periodically for key/value changes?
>> >
>> > Thanks!
>> >
>>
>
>

Re: Getting all the keys in a cache

Posted by Ognen Duzlevski <og...@gmail.com>.
Nice, thanks!

On Mon, Apr 20, 2015 at 12:06 PM, Valentin Kulichenko <
valentin.kulichenko@gmail.com> wrote:

> Ognen,
>
> You can use continuous queries for that:
>
> https://ignite.incubator.apache.org/releases/1.0.0/javadoc/org/apache/ignite/cache/query/ContinuousQuery.html
>
> On Mon, Apr 20, 2015 at 10:02 AM, Ognen Duzlevski <
> ognen.duzlevski@gmail.com
> > wrote:
>
> > Hello,
> >
> > I am looking at the
> > https://ignite.incubator.apache.org/releases/1.0.0/javadoc/ page and I
> > cannot find a method to just get all the keys in a particular cache. All
> > the get() methods require a known key or a set of known keys. What if I
> > have one app that is filling up the cache and another one that is
> > inspecting the same cache periodically for key/value changes?
> >
> > Thanks!
> >
>

Re: Getting all the keys in a cache

Posted by Valentin Kulichenko <va...@gmail.com>.
Ognen,

You can use continuous queries for that:
https://ignite.incubator.apache.org/releases/1.0.0/javadoc/org/apache/ignite/cache/query/ContinuousQuery.html

On Mon, Apr 20, 2015 at 10:02 AM, Ognen Duzlevski <ognen.duzlevski@gmail.com
> wrote:

> Hello,
>
> I am looking at the
> https://ignite.incubator.apache.org/releases/1.0.0/javadoc/ page and I
> cannot find a method to just get all the keys in a particular cache. All
> the get() methods require a known key or a set of known keys. What if I
> have one app that is filling up the cache and another one that is
> inspecting the same cache periodically for key/value changes?
>
> Thanks!
>