Working with cache

Hi!

I wanted to know how can I make use of a cache that is written to the disc. I would like to process methods and store the results somehow (i.e. in the cache) for later use.

Regards,
Bartek.

9 comments

The best method, IMHO, is to implement the
JetBrains.ReSharper.Psi.Caches.ICache interface, and register you cache in
the CacheManager.
Using this way, your implementation will be nitified on changed files, etc.

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"nuwandapl" <no_reply@jetbrains.com> wrote in message
news:23200228.3501233749259882.JavaMail.clearspace@app4.labs.intellij.net...

Hi!

>

I wanted to know how can I make use of a cache that is written to the
disc. I would like to process methods and store the results somehow (i.e.
in the cache) for later use.

>

Regards,
Bartek.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5231363#5231363



0

Hi Eugene!

Thank you for this tip. ICache contains many elements to implement. Can you give me a hint how to implement saving some info (lets say a number) for each method in a class from a give file during analysis? And how to retrieve that info later when running the analysis again?

Thank you in advance for your response.

Bartek.

0

Hello again!

I'm trying to implement my own cache. I did a deep-dive into your ICache implementation and I was wondering what is the purpose of TypePart derivates in regard to caching. Can you give me a hint?

Thank you fro your cooperation.
Bartek.

0

The seccond question is where to register my own cache? I know that I should use a CacheManager but how can I defne an entry point form my plugin?

Bartek.

0

'TypePart' and etc. are the implemetation details of the ReSharper's symbol
index.
The purpose of the abstract ICache is to store any file-dependent
information and to update it when file changes.

To register your ICache you have to call CacheManager.RegisterCache

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Bartlomiej Legiedz" <no_reply@jetbrains.com> wrote in message
news:8884357.311234865447536.JavaMail.clearspace@app4.labs.intellij.net...

Hello again!

>

I'm trying to implement my own cache. I did a deep-dive into your ICache
implementation and I was wondering what is the purpose of TypePart
derivates in regard to caching. Can you give me a hint?

>

Thank you fro your cooperation.
Bartek.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5232258#5232258



0

Thank you Eugene for your quick replay!

I was wondering if there is a special moment when I should register my cache. I can register it when creating my DeamonProcess in DeamonStage but isn't it too late? When do you register your caches in CacheManager?

Regards,
Bartek.

0

This is definitely TOO late.
Usually, you should register your cache on solution component startup.

Please, tell me once more what is your task, and I'll give you hints on
implementation

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Bartlomiej Legiedz" <no_reply@jetbrains.com> wrote in message
news:27854940.1941234872258708.JavaMail.clearspace@app4.labs.intellij.net...

Thank you Eugene for your quick replay!

>

I was wondering if there is a special moment when I should register my
cache. I can register it when creating my DeamonProcess in DeamonStage but
isn't it too late? When do you register your caches in CacheManager?

>

Regards,
Bartek.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5232280#5232280



0

Great!

My aim is to analyze methods. My algorithm will compute some results per method. Then I'd like to store that result in a cache and update it only if the corresponding method has been changed. And of course I'd like to persist that results between visual studio sessions. I want to be able to retrieve that result given a method identity (what identity?) so that my algorithm will be able to compute its result on calls to other methods (and results computed for them). I want to analyze methods that I have source code for (how can you that a given call is made to the methods with source code and not to some framework method?).

That's all about caching. Thank you for your involvement.
Bartek.

0

I see. Things are more complicated then was seen before :)

The ICache & co. wouldn't work for you well here, since they rely that files
are
1) independedt
2) different caches could load/update simultaneous

Your case doesn't suit here because you DO need all symbol indices
up-to-date here (to resolve symbols).

From your description I haven't understood if you would need to re-calculate
the whole solution if some class changes.... If not, then the good way to
implement you behavour is to create the following component which would:
1) Listen to document changes and mark changed files as dirty in your index
2) implement IAsyncClient interface and re-calculate your info in
interruptable background activity (inheriting from InterruptableReadActivity
class)
3) The best way to identify methods is to store their XMLDocId

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Bartlomiej Legiedz" <no_reply@jetbrains.com> wrote in message
news:23099187.2231234875234232.JavaMail.clearspace@app4.labs.intellij.net...

Great!

>

My aim is to analyze methods. My algorithm will compute some results per
method. Then I'd like to store that result in a cache and update it only
if the corresponding method has been changed. And of course I'd like to
persist that results between visual studio sessions. I want to be able to
retrieve
that result given a method identity (what identity?) so that my algorithm
will be able to compute its result on calls to other methods (and results
computed for them). I want to analyze methods that I have source code for
(how can you that a given call is made to the methods with source code and
no
t to some framework method?).

>

That's all about caching. Thank you for your involvement.
Bartek.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5232284#5232284



0

Please sign in to leave a comment.