[ 
https://issues.apache.org/jira/browse/OAK-3005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14589661#comment-14589661
 ] 

Chetan Mehrotra commented on OAK-3005:
--------------------------------------

[~shgu...@adobe.com] Given we already use Guava in Oak it might be better to 
just make use of them and have a simple CachingDataStore impl. Have a look at 
{{DataStoreBlobStore#getInputStream}} where we have some caching done for small 
binaries on heap. 

Extrapolating that design in following way would allow us to implement a simple 
FS based caching layer
# Have a new cache where the cached value is File (or some instance which keeps 
a reference to File)
# Provide support for Weight via a simple 
[Weigher|http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/cache/Weigher.html]
 which is based on File size
# Register a 
[RemovalListener|http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/cache/RemovalListener.html]
 which removes the file from file system upon eviction
# Provide a loader which spools the remote binary to local filesystem

This should be a small logic and would provide you all benefits of Guava cache 
including cache stats. And this would transparently work for any DataStore. 

May be we implement it at {{BlobStore}} level itself and then it would be 
useful for other BlobStore also. Doing it at BlobStore level would require some 
support from {{BlobStore}} to determine the blob length from blobId itself. 

[1] https://code.google.com/p/guava-libraries/wiki/CachesExplained

> OSGI wrapper service for Jackrabbit CachingFDS
> ----------------------------------------------
>
>                 Key: OAK-3005
>                 URL: https://issues.apache.org/jira/browse/OAK-3005
>             Project: Jackrabbit Oak
>          Issue Type: Improvement
>          Components: blob
>    Affects Versions: 1.0.15
>            Reporter: Shashank Gupta
>            Assignee: Shashank Gupta
>              Labels: features, performance
>             Fix For: 1.0.16
>
>         Attachments: OAK-2729.patch
>
>
> OSGI service wrapper for JCR-3869 which provides CachingDataStore 
> capabilities for SAN & NAS storage



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to