David Blume commited on 2016-09-12 20:54:13
Showing 2 changed files, with 15 additions and 4 deletions.
| ... | ... |
@@ -2,6 +2,15 @@ |
| 2 | 2 |
|
| 3 | 3 |
kvs is a rudimentary key/value store written in Python. |
| 4 | 4 |
|
| 5 |
+## Dependencies and Guarantees |
|
| 6 |
+ |
|
| 7 |
+kvs was written as an experiment. The master branch uses a local file for its backing store. Its ACID properties are as follows: |
|
| 8 |
+ |
|
| 9 |
+* **Atomicity**: Either all tuples in a transaction are successfully saved or none are. |
|
| 10 |
+* **Consistency**: Only valid states are saved, and saves are atomic. |
|
| 11 |
+* **Isolation**: All transactions are serialized. |
|
| 12 |
+* **Durability**: System failure or restart won't break the store. Store writes are atomic. |
|
| 13 |
+ |
|
| 5 | 14 |
# Getting the project |
| 6 | 15 |
|
| 7 | 16 |
You can get a copy of this project by clicking on the |
| ... | ... |
@@ -142,9 +142,13 @@ if __name__ == '__main__': |
| 142 | 142 |
with open('auth.txt', 'r') as f:
|
| 143 | 143 |
authorization = f.read().strip() |
| 144 | 144 |
if doing_post and auth == authorization: |
| 145 |
+ print "Content-type: text/plain; charset=utf-8\n" |
|
| 145 | 146 |
for new_key in args: |
| 146 |
- if new_key not in ('auth', ) and \
|
|
| 147 |
- len(new_key) < 80 and len(args[new_key].value) < 140: |
|
| 147 |
+ if new_key =='auth': |
|
| 148 |
+ continue |
|
| 149 |
+ if len(new_key) > 80 or len(args[new_key].value) > 140: |
|
| 150 |
+ print "Error: A key or value was too long." |
|
| 151 |
+ sys.exit(0) |
|
| 148 | 152 |
if new_key in store and 'created' in store[new_key]: |
| 149 | 153 |
created_time = store[new_key]['created'] |
| 150 | 154 |
else: |
| ... | ... |
@@ -155,9 +159,7 @@ if __name__ == '__main__': |
| 155 | 159 |
'origin': os.environ['REMOTE_ADDR']} |
| 156 | 160 |
write_file(os.path.join(localdir, store_name), store) |
| 157 | 161 |
wrote_response = True |
| 158 |
- print "Content-type: text/plain; charset=utf-8\n" |
|
| 159 | 162 |
print "OK" |
| 160 |
- break |
|
| 161 | 163 |
elif not os.environ['QUERY_STRING'] and not doing_post: |
| 162 | 164 |
# just the home page, then |
| 163 | 165 |
print "Content-type: text/plain; charset=UTF-8\n" |
| 164 | 166 |