-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-function.txt
More file actions
16 lines (16 loc) · 806 Bytes
/
create-function.txt
File metadata and controls
16 lines (16 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def create(key,value,timeout=0):
if key in d:
print("error: this key already exists") #error message1
else:
if(key.isalpha()):
if len(d)<(1024*1020*1024) and value<=(16*1024*1024): #constraints for file size less than 1GB and Jasonobject value less than 16KB
if timeout==0:
l=[value,timeout]
else:
l=[value,time.time()+timeout]
if len(key)<=32: #constraints for input key_name capped at 32chars
d[key]=l
else:
print("error: Memory limit exceeded!! ")#error message2
else:
print("error: Invalind key_name!! key_name must contain only alphabets and no special characters or numbers")#error message3