forked from ziyuang/mincemeatpy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcacheTest.py
69 lines (47 loc) · 1.28 KB
/
cacheTest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import pickle
from functools4 import lru_cache
from cacheData import CacheData
@lru_cache(maxsize=None)
def fib(key,url):
return url
def checkCache(key):
result=fib.checkCache(key);
return result;
def writeToCache(key,url):
fib(key,url)
# open a file, where you stored the pickled data
file = open('important', 'rb')
# dump information to that file
cacheData = pickle.load(file)
# close the file
file.close()
#fib.set_cache_dictionary(result)
#print(fib.cache_info())
fib.set_cache_dictionary(cacheData.cache,cacheData.root,cacheData.hit,cacheData.full)
cache=fib.get_cache_dictionary()
for x in range(54,65):
result=checkCache(x)
if result is None:
print("Writing to Cache now")
writeToCache(x,chr(x))
else:
print("hit---"+str(result) )
print("Stage 2")
for x in range(65,80):
result=checkCache(x)
if result is None:
print("Writing to Cache now")
writeToCache(x,chr(x))
else:
print("hit---"+str(result) )
print("Stage 3")
for x in range(54,80):
result=checkCache(x)
if result is None:
print("Writing to Cache now")
writeToCache(x,chr(x))
else:
print("hit---"+str(result) )
#for x in range(16):
# fib(x)
#print(fib.cache_info())