Caching
BrightstarDB provides facilities for caching the results of SPARQL queries both in memory and to disk. Caching complex SPARQL queries or queries that potentially return large numbers of results can provide a significant performance improvement. Caching is controlled through a combination of settings in the application configuration file (the web.config for web apps, or the .exe.config for other executables).
|
AppSetting Key |
Default Value |
Description |
|
BrightstarDB.EnableQueryCache |
false |
Boolean value ("true" or "false") that specifies if the system should cache the result of SPARQL queries. |
|
BrightstarDB.QueryCacheMemory |
256 |
The size in MB of the in-memory query cache. |
|
BrightstarDB.QueryCacheDirectory |
<undefined> |
The path to the directory to be used for the disk cache. If left undefined, then the behaviour depends on whether the BrightstarDB.StoreLocation setting is provided. If it is, then a disk cache will be created in the _bscache subdirectory of the StoreLocation, otherwise disk caching will be disabled. |
|
BrightstarDB.QueryCacheDiskSpace |
2048 |
The size in MB of the disk cache. |
Example Configurations
To cache in the _bscache subdirectory of a fixed store location (a good choice for server applications), it is necessary only to enable caching and ensure that the store location is specified in the configuration file:
<configuration>
<appSettings>
<add key="BrightstarDB.EnableQueryCache" value="true" />
<!-- disk cache will be written to the directory d:\brightstar\_bscache -->
<add key="BrightstarDB.StoreLocation" value="d:\brightstar\" />
</appSettings>
</configuration>
To cache in some other location (e.g. a fast disk dedicated to caching):
<configuration>
<appSettings>
<add key="BrightstarDB.EnableQueryCache" value="true" />
<add key="BrightstarDB.StoreLocation" value="d:\brightstar\" />
<!-- Cache on a different disk from the B* stores to maximize disk throughput.
Disk cache will be written to the directory e:\bscache -->
<add key="BrightstarDB.QueryCacheDirectory" value="e:\bscache\"/>
<!-- Allow disk cache to grow to up to 200GB in size -->
<add key="BrightstarDB.QueryCacheDiskSpace" value="204800" />
</appSettings>
</configuration>
This sample has no disk cache because there is no valid location for the cache to be created:
<configuration>
<appSettings>
<add key="BrightstarDB.EnableQueryCache" value="true" />
<!-- 1GB in-memory cache -->
<add key="BrightstarDB.QueryCacheMemory" value=1024"/>
<!-- This property is not used because there is no
BrightstarDB.QueryCacheDirectory or
BrightstarDB.StoreLocation setting defined. -->
<add key="BrightstarDB.QueryCacheDiskSpace" value="204800" />
</appSettings>
</configuration>
