LruCache

16 views
Skip to first unread message

Eugeny Kozhanov

unread,
Oct 1, 2012, 6:38:52 AM10/1/12
to ne...@googlegroups.com
I use Lru cache in my plugin:
LruCache<String, List<String>> lruc = new LruCache<String, List<String>>("myLruCache", 1);

Why cache is flushing before each request of my plugin method?

Mattias Persson

unread,
Oct 1, 2012, 6:43:55 AM10/1/12
to ne...@googlegroups.com
You pass in 1 in the constructor... that is maxSize=1, which pretty much makes your LruCache equivalent to a String reference to the last string inserted into it.

2012/10/1 Eugeny Kozhanov <vin...@gmail.com>
I use Lru cache in my plugin:
LruCache<String, List<String>> lruc = new LruCache<String, List<String>>("myLruCache", 1);

Why cache is flushing before each request of my plugin method?

--
 
 



--
Mattias Persson, [mat...@neotechnology.com]
Hacker, Neo Technology
www.neotechnology.com

Eugeny Kozhanov

unread,
Oct 1, 2012, 6:46:33 AM10/1/12
to ne...@googlegroups.com
thanks! I set 1000.

Did LRU cache use follow parameters:
node_cache_size = 2G
relationship_cache_size = 1G
?

Mattias Persson

unread,
Oct 1, 2012, 6:48:16 AM10/1/12
to ne...@googlegroups.com
No, those are only used by the "gcr" cache, available in the enterprise packaging of neo4j.

2012/10/1 Eugeny Kozhanov <vin...@gmail.com>

Eugeny Kozhanov

unread,
Oct 1, 2012, 6:51:40 AM10/1/12
to ne...@googlegroups.com
Can I know cache used memory?

Eugeny Kozhanov

unread,
Oct 1, 2012, 6:55:47 AM10/1/12
to ne...@googlegroups.com
value of used memory (in megabytes, for example)

Mattias Persson

unread,
Oct 1, 2012, 7:21:22 AM10/1/12
to ne...@googlegroups.com
No, it doesn't tell you that, just how many items it has, via the size() method.

2012/10/1 Eugeny Kozhanov <vin...@gmail.com>

Eugeny Kozhanov

unread,
Oct 1, 2012, 7:31:31 AM10/1/12
to ne...@googlegroups.com
Thank you! I try use it.

Eugeny Kozhanov

unread,
Oct 1, 2012, 7:33:52 AM10/1/12
to ne...@googlegroups.com
and some small question: this cache use RAM? it's included into Java Heap Space?

Mattias Persson

unread,
Oct 1, 2012, 8:50:05 AM10/1/12
to ne...@googlegroups.com


2012/10/1 Eugeny Kozhanov <vin...@gmail.com>

and some small question: this cache use RAM? it's included into Java Heap Space?

Yes

Eugeny Kozhanov

unread,
Oct 1, 2012, 9:06:22 AM10/1/12
to ne...@googlegroups.com
Thanks a lot!

Eugeny Kozhanov

unread,
Oct 2, 2012, 12:41:55 AM10/2/12
to ne...@googlegroups.com
Cache will flush after stop server. Can I save this to file? How I read this from file before restart the server?

Mattias Persson

unread,
Oct 2, 2012, 3:27:03 AM10/2/12
to ne...@googlegroups.com
The LruCache class in neo4j is merely a wrapped LinkedHashMap, there's nothing more fancy to it I'm afraid.

2012/10/2 Eugeny Kozhanov <vin...@gmail.com>

Michael Hunger

unread,
Oct 2, 2012, 3:28:55 AM10/2/12
to ne...@googlegroups.com
If you need something like that, then dumping the content (ie. keys & node-id's) of the cache to a file and repopulating it at startup should be easy for you.

Michael

--
 
 

Eugeny Kozhanov

unread,
Oct 3, 2012, 12:46:39 AM10/3/12
to ne...@googlegroups.com
That is good idea, thanks!
Reply all
Reply to author
Forward
0 new messages