private IDocumentCacher CreateDocumentCacher(InMemoryRavenConfiguration configuration)
        {
            if (configuration.CacheDocumentsInMemory == false)
            {
                documentCacher = new NullDocumentCacher();
            }
            else if (configuration.CustomMemoryCacher != null)
            {
                documentCacher = configuration.CustomMemoryCacher(configuration);
            }
            else
            {
                documentCacher = new DocumentCacher(configuration);
            }

            return(documentCacher);
        }
Example #2
0
        public TransactionalStorage(InMemoryRavenConfiguration configuration, Action onCommit, Action onStorageInaccessible, Action onNestedTransactionEnter, Action onNestedTransactionExit)
        {
            configuration.Container.SatisfyImportsOnce(this);

            if (configuration.CacheDocumentsInMemory == false)
            {
                documentCacher = new NullDocumentCacher();
            }
            else if (configuration.CustomMemoryCacher != null)
            {
                documentCacher = configuration.CustomMemoryCacher(configuration);
            }
            else
            {
                documentCacher = new DocumentCacher(configuration);
            }

            database           = configuration.DataDirectory;
            this.configuration = configuration;
            this.onCommit      = onCommit;

            path = database;
            if (Path.IsPathRooted(database) == false)
            {
                path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, database);
            }
            database = Path.Combine(path, "Data");

            RecoverFromFailedCompact(database);

            new TransactionalStorageConfigurator(configuration, this).LimitSystemCache();

            uniquePrefix = Interlocked.Increment(ref instanceCounter) + "-" + Base62Util.Base62Random();
            CreateInstance(out instance, uniquePrefix + "-" + database);
            this.onNestedTransactionEnter = onNestedTransactionEnter;
            this.onNestedTransactionExit  = onNestedTransactionExit;
        }