예제 #1
0
def cause_a_to_do_something():
    import code as x

    x.create(
        "Aakash", 25
    )  #to create a key with key_name,value given and with no time-to-live property
    x.create(
        "src", 50, 120
    )  #to create a key with key_name,value given and with time-to-live property value given(number of seconds)
    x.read(
        "Aakash"
    )  #it returns the value of the respective key in Jasonobject format 'key_name:value'
    x.read(
        "src"
    )  #it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

    x.create("Aakash", 50)

    x.delete(
        "Aakash"
    )  #it deletes the respective key and its value from the database(memory is also freed)
    #we can access these using multiple threads like
    t1 = Thread(target=(create or read or delete),
                args=(key_name, value, timeout))  #as per the operation
    t1.start()
    t1.sleep()
    t2 = Thread(target=(create or read or delete),
                args=(key_name, value, timeout))  #as per the operation
    t2.start()
    t2.sleep()
    x.do_something()
예제 #2
0
                  "has expired")  #error message5
    else:
        if key not in d:
            print(
                "error: given key does not exist in database. Please enter a valid key"
            )  #error message6
        else:
            l = []
            l.append(value)
            l.append(b[1])
            d[key] = l


while (1):
    print("choose one operation: 1.create 2.read 3.modify 4.delete")
    n = int(input())
    if (n == 1):
        input1 = input("enter the key ")
        value = int(input("enter the vaue "))
        x.create(input1, value)
    elif (n == 2):
        input2 = input("enter the key ")
        print(x.read(input2))
    elif (n == 3):
        input3 = input("enter the key ")
        value1 = int(input("enter the value "))
        x.modify(input3, value1)
    elif (n == 4):
        input4 = input("enter the key ")
        x.delete(input4)
import code as x 

x.create("tom",25)

x.create("src",70,3600) 

x.read("tom")

x.read("src")

x.create("tom",50)

x.modify("tom",55)
 
x.delete("tom")

#using multiple threads 
t1=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t1.start()
t1.sleep()
t2=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t2.start()
t2.sleep()
예제 #4
0
#import as library
import code
#key and value with no expTime
code.create("A", {"AAA": 1})
code.create("B", {"BBB": 2})
#key,value and expireTime
code.create("C", {"CCC": 3}, 10)
code.create("D", {"DDD": 4}, 1)
#Read operation
code.read("A")
code.read("B")
#delete operation
code.delete("A")
#for multithreading
#t1=Thread(target=function,args=arguments)
t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
#starting thread 1
t1.start()
t1.join()
t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
#starting thread 2
t2.start()
t2.join()
예제 #5
0
import code as x
x.create("suji", 25)
x.create("src", 70, 3600)
x.read("suji")
x.read("src")
x.create("suji", 50)
x.modify("suji", 55)
x.delete("suji")
t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t1.start()
t1.sleep()
t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t2.start()
t2.sleep()
예제 #6
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("ABC", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("DEF", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("ABC")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("DEF")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("ABC", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("ABC", 55)
#it replaces the initial value of the respective key with new value

x.delete("ABC")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #7
0
import code as c
# importing the code file as a library 


c.create("karthi",25)# to create a key with no time-to-live property


c.create("lee",70,5) # to create a key with time-to-live property


c.read("karthi")# it returns the value of the respective key in Jasonobject format 'key_name:value'

c.read("lee")# it returns the value of respective key in jasonobject format if time-to-live property is not expired else it returns error message

c.delete("karthi")#it deletes the key and its value from datastore

#we can access the code using multi-thread by following code

t1=c.threading.Thread(target=c.create,args=("karthi",21,))
t1.start()
t2=c.threading.Thread(target=c.read,args=("lee",))
t2.start()
예제 #8
0
import code as x
import threading
from threading import *
path = x.create_file()  # Path for creating a file run only once
path = 'data.json'
x.create('Andhra Pradesh', 'Vijayawada', path, 20)
x.read('Andhra Pradesh', path)
x.create('Telangana', 'Hyderabad', path, 20)
x.delete('Telangana', path)
t1 = Thread(target=(x.delete),
            args=('Karnataka',
                  path))  # This code can also access db using multiple threads
t2 = Thread(target=(x.create), args=('Maharashtra', 'Mumbai', path))
t2.start()
t1.start()
#run the MODULE of MAIN FILE and import mainfile as a library 

import code as x 
#importing the main file("code" is the name of the file I have used) as a library 


x.create("saveetha",25)
#to create a key with key_name,value given and with no time-to-live property


x.create("sav",70,3600) 
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)


x.read("saveetha")
#it returns the value of the respective key in Jasonobject format 'key_name:value'


x.read("sav")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR


x.create("saveetha",50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error 
#either use modify operation to change the value of a key
#or use delete operation and recreate it


x.modify("saveetha",55)
예제 #10
0
import sys
import code as x 
# importing the main file("code" is the name of the file I have used) as a library

if sys.version_info < (3, 0):
    from thread import *
else:
    from threading import Thread
    
x.create("srctest", 25)
# to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
# to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("srctest")
# it returns the value of the respective key in Json object format 'key_name:value'


x.read("src")
# it returns the value of the respective key in Json object format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR


x.create("srctest", 50)
# it returns an ERROR since the key_name already exists in the database
# To overcome this error use delete operation and recreate it

x.delete("srctest")
# it deletes the respective key and its value from the database(memory is also freed)

# we can access these using multiple threads like
import code as x 
#importing the main file("code" is the name of the file I have used) as a library 


x.create("freshworks",25)
#to create a key with key_name,value given and with no time-to-live property


x.create("fresh",70,120) 
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)


x.read("freshworks")
#it returns the value of the respective key in Jasonobject format 'key_name:value'


x.read("fresh")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR


x.create("freshworks",50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error 
#either use modify operation to change the value of a key
#or use delete operation and recreate it


x.modify("freshworks",55)
#it replaces the initial value of the respective key with new value 

 
예제 #12
0
import code as x
x.create("abcdef", 25)
x.create("ski", 70, 3600)  #create a key with key_name

x.read("abcdef")  #returns the value of key_name
x.read("ski")
#returns the value of the respective key in Jasonobject

x.create("abcdef", 50)
x.modify("abcdef",
         55)  #replaces the initial value of the respective key with new value

x.delete("abcdef")
t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t1.start()
t1.sleep()
t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t2.start()
t2.sleep()
예제 #13
0
import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("Dinesh", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("Amrita", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("Dinesh")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("Amrita")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("Dinesh", 50)
#it returns an ERROR since the key_name already exists in the database

x.modify("Dinesh", 55)
#it replaces the initial value of the respective key with new value

x.delete("Dinesh")
#it deletes the respective key and its value from the database(memory is also freed)

#we can access these using multiple threads like
t1 = Thread(target=(create or read or delete),
            args=(key_name, value, timeout))  #as per the operation
t1.start()
t1.sleep()
t2 = Thread(target=(create or read or delete),
            args=(key_name, value, timeout))  #as per the operation
예제 #14
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("Tippu", 50)
#to create a key with key_name,value given and with no time-to-live property

x.create("Sulthan", 60, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("Tippu")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("Sulthan")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("Tippu", 75)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("Tippu", 55)
#it replaces the initial value of the respective key with new value

x.delete("Tippu")
#it deletes the respective key and its value from the database(memory is also freed)
import code as x 
import threading as Thread
_db_lock=Thread.Lock()

x.create("rani",50)
x.create("src",70,3600) 
x.read("rani")
x.read("src")
x.create("rani",70)
x.modify("rani",75)
x.delete("rani")

t1=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t1.start()
t1.sleep()
t2=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t2.start()
t2.sleep()
예제 #16
0
import code as x
x.create("rattj", 25)
x.create("src", 70, 3600)
x.read("rattj")
x.read("src")
x.create("rattj", 50)
x.modify("rattj", 55)
x.delete("rattj")
t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t1.start()
t1.sleep()
t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t2.start()
t2.sleep()
예제 #17
0
from threading import*
import threading
import code as x

x.create("shrutika",218)

x.read("shrutika")
x.create("vanga",703)
x.read("vanga")
x.create("akanksha",50)
x.modify("shrutika",55)
x.delete("akanksha")
x.read("akanksha")




예제 #18
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library
import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("raghul", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("covid", 70)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("raghul")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("covid")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("raghul", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("raghul", 55)
#it replaces the initial value of the respective key with new value

x.delete("raghul")
#it deletes the respective key and its value from the database(memory is also freed)

#we can access these using multiple threads like
예제 #19
0
import code as x

x.create("shiwani", 21)

x.create("mishra", 70, 3600)

x.read("shiwani")

x.read("mishra")

x.create("shiwani", 50)
x.delete("shiwani")
t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t1.start()
t1.sleep()
t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout))
t2.start()
t2.sleep()
예제 #20
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("Freshworks", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("Freshworks")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("Freshworks", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("Freshworks", 55)
#it replaces the initial value of the respective key with new value

x.delete("Freshworks")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #21
0
#run the MODULE of MAIN FILE and import mainfile as a library 

import code as K
#Here code refers to the code file that i posted here.


K.create("Enjoyment",42)
#it creates a key with key_name,value given and with no time-to-live property


K.create("Issues",70,4500) 
#it creates a key with key_name,value given and with time-to-live property value given(number of seconds)


K.read("Issues")
#it returns the value of the respective key in Jasonobject format 'key_name:value'


K.read("Enjoyment")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR


K.create("Issues",70)
#it returns an ERROR since the key_name already exists in the database


 
K.delete("Enjoyment")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #22
0
import code as x

x.create(
    "Andrea", 25
)  #to create a key with key_name,value given and with no time-to-live property

x.create(
    "src", 50, 120
)  #to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read(
    "Andrea"
)  #it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read(
    "src"
)  #it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create(
    "Andrea",
    50)  #it returns an ERROR since the key_name already exists in the database
#use delete operation and recreate it

x.delete(
    "Andrea"
)  #it deletes the respective key and its value from the database(memory is also freed)

#we can access these using multiple threads like
t1 = Thread(target=(create or read or delete),
            args=(key_name, value, timeout))  #as per the operation
t1.start()
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("dog", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("dog")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("dog", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("dog", 55)
#it replaces the initial value of the respective key with new value

x.delete("sastra")
#it deletes the respective key and its value from the database(memory is also freed)
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("rgukt", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("rgukt")
#it returns the value of the respective key in Jsonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jsonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("rgukt", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("rgukt", 55)
#it replaces the initial value of the respective key with new value

x.delete("rgukt")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #25
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("jntu", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("jntu")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("jntu", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("jntu", 55)
#it replaces the initial value of the respective key with new value

x.delete("jntu")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #26
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create("fdfhfy", 78)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 87, 7786)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("fdfhfy")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("fdfhfy", 98)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("fdfhfy", 85)
#it replaces the initial value of the respective key with new value

x.delete("fdfhfy")
#it deletes the respective key and its value from the database(memory is also freed)
예제 #27
0
#run the MODULE of MAIN FILE and import mainfile as a library 
import threading

import code as x 
#importing the main file("code" is the name of the file I have used) as a library 


x.create("sastra",25)
#to create a key with key_name,value given and with no time-to-live property


x.create("src",70,3600) 
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)


x.read("sastra")
#it returns the value of the respective key in Jasonobject format 'key_name:value'


x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR


x.create("sastra",50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error 
#either use modify operation to change the value of a key
#or use delete operation and recreate it


x.modify("sastra",55)
예제 #28
0
 import code as x 

x.create("Hello",25)

x.create("src",70,3600) 

x.read("Hello")

x.read("src")

x.create("Hello",50)

x.modify("Hello",55)
 
x.delete("Hello")

t1=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t1.start()
t1.sleep()
t2=Thread(target=(create or read or delete),args=(key_name,value,timeout)) 
t2.start()
t2.sleep()
예제 #29
0
#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
#importing the main file("code" is the name of the file I have used) as a library

x.create(
    "preet",
    15,
)
#to create a key with key_name,value given and with no time-to-live property

x.create("kaur", 7, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("preet")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("kaur")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("preet", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("preet", 55)
#it replaces the initial value of the respective key with new value

x.delete("preet")
예제 #30
0
#here are the commands to demonstrate how to access and perform operations on a main file

#run the MODULE of MAIN FILE and import mainfile as a library

import code as x
from threading import Thread
#importing the main file("code" is the name of the file I have used) as a library

x.create("Amrita", 25)
#to create a key with key_name,value given and with no time-to-live property

x.create("src", 70, 3600)
#to create a key with key_name,value given and with time-to-live property value given(number of seconds)

x.read("Amrita")
#it returns the value of the respective key in Jasonobject format 'key_name:value'

x.read("src")
#it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR

x.create("Amrita", 50)
#it returns an ERROR since the key_name already exists in the database
#To overcome this error
#either use modify operation to change the value of a key
#or use delete operation and recreate it

x.modify("Amrita", 55)
#it replaces the initial value of the respective key with new value

x.delete("Amrita")
#it deletes the respective key and its value from the database(memory is also freed)