Never mind, stupid, stupid me. Too much work, not enough fun.
Ognen
On Mon, Jul 6, 2015 at 7:59 AM, Ognen Duzlevski <[email protected]>
wrote:
> Hello,
>
> I am getting a strange compile error when trying to write my own cache
> store in Scala:
>
> [error]
> /Users/ognen.duzlevski/code/test/src/main/scala/com/ognenduz/test/Cacheable.scala:79:
> type mismatch;
> [error] found :
> javax.cache.configuration.Factory[com.ognenduz.test.PostCacheStore]
> [error] required: javax.cache.configuration.Factory[_ <:
> org.apache.ignite.cache.store.CacheStore[_ >: K, _ >: V]]
> [error]
> cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
>
> Here is how the below PostCacheStore is set up with the cache
> configuration:
>
>
> cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(classOf[PostCacheStore]))
>
> Below is the basic implementation of the cache store for test purposes -
> it just writes and reads from elastic search. In addition, note the
> required signature for the write() method - the compiler failed and failed
> until I fed it the exact signature/syntax - it seems odd that it would have
> to be fed exactly that. I am not much of a Java programmer so any
> help/hints are appreciated. Thanks!
>
> class PostCacheStore extends CacheStoreAdapter[String,Post] {
>
> implicit val formats = Serialization.formats(NoTypeHints)
>
> // get client access to eclipse
> val e = ElasticClient.remote("localhost", 9300)
>
> // This method is called whenever "get(...)" methods are called on
> IgniteCache.
> override def load(key:String):Post = {
> val r = e.execute {
> get id key.toString from "posts"
> }.await
> read[Post](r.getSourceAsString)
> }
>
> override def write(k:javax.cache.Cache.Entry[_<:String,_<:Post]): Unit =
> {
> //println("invoking!")
> e.execute({
> index into "posts" source k.getValue
> })
> }
>
> // FIXME: implement the delete method at some point
> override def delete(k:Any):Unit = {}
> }
>