Skip to content

Commit

Permalink
Adding expiration for the document cache, would avoid situation where…
Browse files Browse the repository at this point in the history
… we have a lot of documents in memory that we no longer reference
  • Loading branch information
ayende committed Aug 3, 2011
1 parent 0a2c21a commit fe011d1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Raven.Database/Impl/DocumentCacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Raven.Database.Impl
public class DocumentCacher : IDocumentCacher
{
private readonly MemoryCache cachedSerializedDocuments;

[ThreadStatic]

private static bool skipSettingDocumentInCache;

public DocumentCacher(InMemoryRavenConfiguration configuration)
Expand Down Expand Up @@ -52,11 +52,15 @@ public void SetCachedDocument(string key, Guid etag, RavenJObject doc, RavenJObj
documentClone.EnsureSnapshot();
var metadataClone = ((RavenJObject)metadata.CloneToken());
metadataClone.EnsureSnapshot();
cachedSerializedDocuments["Doc/" + key + "/" + etag] = new CachedDocument
cachedSerializedDocuments.Set("Doc/" + key + "/" + etag, new CachedDocument
{
Document = documentClone,
Metadata = metadataClone
};
}, new CacheItemPolicy
{
SlidingExpiration = TimeSpan.FromMinutes(5),
});

}

public void RemoveCachedDocument(string key, Guid etag)
Expand Down

0 comments on commit fe011d1

Please sign in to comment.