2

I have to design a way to stream data in Scala/Java, with a certain delay compared to the moment I receive the data. I have an API for my original data source (the real time one) which lets me query it as it was a database, using a query-like format, and also to get notification when something happens, much as with EHCACHE.

Now I want for example to stream data with different delays, according to the user privileges. Some of the users will see data streamed with 0 delay, other with 15 minutes, other with 60 minutes.

I will therefore need a top-level cache composed of multiple lower level caches (0 delay, 15 min delay, 60 min delay).

  1. In a first moment I would like the cache to contain only elements of the same type. This would make the things simpler, because I can decide for a unique ID for the elements and I would have only to route the request to the right cache according to the required delay

  2. In a second moment, I would like my delayed cache to be queryable. Is there a part of the code from EHCache which I can recycle, for example?

4

1 に答える 1

2

アイデア: ストリーム データを、 Delayedを実装するある種のイベント オブジェクトに変換します。このようなリアルタイム イベントが発生するとすぐに、それをDelayedQueueに入れます。その後、別のスレッドがサイクルでtake()を呼び出し、遅延イベントを取得して処理できます。

于 2012-08-16T12:57:29.147 に答える