diff --git a/README.rst b/README.rst index 1cbb643..07edb7c 100644 --- a/README.rst +++ b/README.rst @@ -9,6 +9,12 @@ The primary goal is to provide a lib for easily writing Hydra-enabled clients [1 A secondary goal is to provide a client for Triple Patterns Fragments [2]_, and an RDFlib [3]_ Store backed on any TPF service. +Using Redis to cache the data at the end of client. + +So, Data load from the server and store in Redis memory as a graph. + +With the help of Redis, clients becomes faster and easier to query the data. + Installation ++++++++++++ @@ -16,12 +22,24 @@ To install this library, from the projet directory, type:: pip install . +or + + python3 setup.py install + NB: developers might want to add the ``-e`` option to the command line above, so that modifications to the source are automatically taken into account. +For install redis and start redis-server:: + + cd hydra_redis + ./redis_setup.sh + Quick start +++++++++++ +For hydra.__init__.py +--------------------- + To create a Hydra-enabled resource, use: .. code:: python @@ -82,6 +100,84 @@ so that TPF services can be used transparently: Note however that this is experimental at the moment... + +For hydra_redis +--------------- + +For running the client you should run querying_mechanism + + cd hydra_redis + + python3 querying_mechanism.py + +and provide a valid url and then you can query in querying format. + + >>>help # it will provide the querying format + +Code simplification +^^^^^^^^^^^^^^^^^^^ +To create graph in Redis memory use: + +.. code:: python + + import redis + from redisgraph import Graph, Node, Edge + redis_con = redis.Redis(host='localhost', port=6379) + self.redis_graph = Graph("apidoc", redis_con) + + +For querying, url should be provided first: + +.. code:: python + + url = input("url>>>") + + return query(apidoc, url) # apidoc is vocab file provided by url. + +.. code:: python + + while True: + print("press exit to quit") + query = input(">>>") + if query == "exit": + break + elif query == "help": + help() # provide querying format + else: + print(facades.user_query(query))# query can be done with facades class + + +you can query in various formats: + +.. code:: python + + print("for endpoint:- show endpoint") + print("for class_endpoint:- show classEndpoint") + print("for collection_endpoint:- show collectionEndpoint") + print("for members of collection_endpoint:-", + "show members") + print("for properties of any member:-", + "show object properties ") + print("for properties of objects:-show objects properties") + print("for collection properties:-", + "show properties") + print("for classes properties:- show class properties") + print("for compare properties:-show and/or ") + + +Query can be done like this: + +.. code:: python + + check_data = [['p.id', 'p.operations', 'p.properties', 'p.type'], + ['vocab:EntryPoint/Location', + "['POST'", "'PUT'", "'GET']", + "['Location']", 'Location']] + query = "show classEndpoints" + self.assertEqual(data,check_data) #data is data retrieve from the Redis. + +For more detail take a look at [wiki file](https://github.com/HTTP-APIs/http-apis.github.io/blob/master/hydra-agent-redis-graph.md) + References ++++++++++