Last change
on this file since 345 was 325, checked in by alloc, 6 years ago |
Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)
|
File size:
733 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.IO;
|
---|
4 |
|
---|
5 | namespace AllocsFixes.FileCache {
|
---|
6 | // Caching all files, useful for completely static folders only
|
---|
7 | public class SimpleCache : AbstractCache {
|
---|
8 | private readonly Dictionary<string, byte[]> fileCache = new Dictionary<string, byte[]> ();
|
---|
9 |
|
---|
10 | public override byte[] GetFileContent (string filename) {
|
---|
11 | try {
|
---|
12 | lock (fileCache) {
|
---|
13 | if (!fileCache.ContainsKey (filename)) {
|
---|
14 | if (!File.Exists (filename)) {
|
---|
15 | return null;
|
---|
16 | }
|
---|
17 |
|
---|
18 | fileCache.Add (filename, File.ReadAllBytes (filename));
|
---|
19 | }
|
---|
20 |
|
---|
21 | return fileCache [filename];
|
---|
22 | }
|
---|
23 | } catch (Exception e) {
|
---|
24 | Log.Out ("Error in SimpleCache.GetFileContent: " + e);
|
---|
25 | }
|
---|
26 |
|
---|
27 | return null;
|
---|
28 | }
|
---|
29 | }
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.