chibenwa opened a new pull request, #2740:
URL: https://github.com/apache/james-project/pull/2740

   # Why ?
   
   Some mail user agents relies on *partial body retrieval* in order to 
simulate "streaming" (and catching back upon transmission errors within a 
message scope)
   
   This is most notably true for IOS clients which issues commands like:
   
   ```
   UID FETCH xx FetchData{items=[UID], setSeen=false, 
bodyElements=[BodyFetchElement{firstOctet=0, numberOfOctets=10024, 
name=BODY[1.1], sectionType=CONTENT}]
   ```
   
   (so streaming not the bytes of the message but of it's individual subparts - 
we simply cannot work offset into S3)
   
   Using chuncks of 10024 bytes means that in order to download a 10MB files ~ 
1000 requests needs to be done and thus 1000 S3 reads.
   
   # Proposal
   
   Cache for FETCH of partial body content. (we can bet on locality as a given 
connection will be used)
   
   If the fetch concerns a single email and if the fetch includes "streaming of 
a body part" via the numberOfOctets + firstOctet either of them being non zero 
then cache !
   
   If querying such a request lookup the cache first before reading the store. 
   
   Implementation details: 
   
    - Use the map of the IMAPSession in order to store the body of the last 
partial fetched message
    - Use a global atomiclong to track the cache size and enforce it do not 
exceed a configured maximum
    - Schedule a netty task to cleanup the cache entry after 30 seconds
    - Values MUST be wrapped in Weak references in order not to be moved into 
old generation by the GC where it would cause memory problems.
    - Debug logs upon cache hits, misses in order to review the efficiency of 
this mechanism
   
   Let's not use a "global cache" eg with caffeine in order to by design 
prevent cross account data leaks.
   
   Default behaviour: NEVER cache.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to