Re: Getting all the keys in a cache

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Getting all the keys in a cache

Ognen Duzlevski
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 <[hidden email]
> wrote:

> Nice, thanks!
>
> On Mon, Apr 20, 2015 at 12:06 PM, Valentin Kulichenko <
> [hidden email]> 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 <
>> [hidden email]
>> > 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!
>> >
>>
>
>