### Production Install FalkorDBLite Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Perform a production-ready installation that automatically handles all setup steps. ```bash # Build and install (not editable) python setup.py install # Or use pip without -e flag pip install . ``` -------------------------------- ### Install Dependencies Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Install necessary project dependencies from the requirements file. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies and Build FalkorDB Lite from Source Source: https://github.com/falkordb/falkordblite/blob/master/README.md Installs runtime dependencies and then builds and installs FalkorDB Lite from its source code. This process includes compiling Redis and downloading the FalkorDB module. ```console pip install -r requirements.txt python setup.py install ``` -------------------------------- ### Install tox Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/contributing.md Install the tox tool using pip. This is a prerequisite for most development tasks. ```bash pip install tox ``` -------------------------------- ### Development Installation of FalkorDB Lite Source: https://github.com/falkordb/falkordblite/blob/master/README.md Sets up FalkorDB Lite for development within a virtual environment. This includes installing build and runtime dependencies, building the project, and installing it in editable mode. ```console # Create and activate a virtual environment python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install build dependencies pip install setuptools wheel # Install runtime dependencies pip install -r requirements.txt # Build the project (this compiles Redis and copies binaries automatically) python setup.py build # Install in editable mode for development pip install -e . ``` -------------------------------- ### FastAPI Integration with AsyncFalkorDB Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Integrate AsyncFalkorDB with FastAPI for building asynchronous web APIs. This example demonstrates initializing the database, handling startup and shutdown events, and defining GET and POST endpoints for managing 'Person' data using parameterized queries. ```python from fastapi import FastAPI from redislite import AsyncFalkorDB app = FastAPI() # Initialize the database db = AsyncFalkorDB('/tmp/api.db') @app.on_event("startup") async def startup(): # Database is already initialized pass @app.on_event("shutdown") async def shutdown(): await db.close() @app.get("/person/{name}") async def get_person(name: str): g = db.select_graph('social') # Use parameterized queries to prevent injection result = await g.ro_query( 'MATCH (p:Person {name: $name}) RETURN p.name, p.age', params={'name': name} ) if result.result_set: return {"name": result.result_set[0][0], "age": result.result_set[0][1]} return {"error": "Person not found"} @app.post("/person") async def create_person(name: str, age: int): g = db.select_graph('social') # Use parameterized queries to prevent injection await g.query( 'CREATE (p:Person {name: $name, age: $age})', params={'name': name, 'age': age} ) return {"status": "created", "name": name, "age": age} ``` -------------------------------- ### hotkeys_start Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Start collecting hotkeys data. ```APIDOC ## hotkeys_start ### Description Start collecting hotkeys data. Returns an error if there is an ongoing collection session. ### Method APICALL ### Endpoint hotkeys_start ### Parameters #### Query Parameters - **metrics** (List[HotkeysMetricsTypes]) - Required - List of metrics to track. Supported values: [HotkeysMetricsTypes.CPU, HotkeysMetricsTypes.NET]. - **count** (int) - Optional - The number of keys to collect in each criteria (CPU and network consumption). - **duration** (int) - Optional - Automatically stop the collection after duration seconds. - **sample_ratio** (int) - Optional - Commands are sampled with probability 1/ratio (1 means no sampling). - **slots** (List[int]) - Optional - Only track keys on the specified hash slots. - **kwargs** - Optional - Additional keyword arguments. ### Response #### Success Response - **return_value** (bytes | str) - Confirmation of session start. ``` -------------------------------- ### Install Build Tools on RHEL/Fedora Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Install required build tools for FalkorDBLite on RHEL or Fedora-based systems. ```bash yum install python3-devel gcc make ``` -------------------------------- ### Editable Install FalkorDBLite Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Install FalkorDBLite in editable mode after building. ```bash pip install -e . ``` -------------------------------- ### Install Xcode Command Line Tools (macOS) Source: https://github.com/falkordb/falkordblite/blob/master/README.md Installs the Xcode command line utilities required for building FalkorDB Lite from source on macOS. Run this command if you do not have Xcode installed or if the tools are missing. ```bash xcode-select --install ``` -------------------------------- ### hotkeys_start Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Start collecting hotkeys data with specified metrics and parameters. ```APIDOC ## hotkeys_start ### Description Start collecting hotkeys data. Returns an error if there is an ongoing collection session. ### Method Not specified (likely part of a client library) ### Endpoint Not specified ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response - **Return Value** (bytes | str | Awaitable[bytes | str]) - Confirmation of session start. #### Response Example None ### Parameters * **count** (int | None) - The number of keys to collect in each criteria (CPU and network consumption). * **metrics** (List[HotkeysMetricsTypes]) - List of metrics to track. Supported values: [HotkeysMetricsTypes.CPU, HotkeysMetricsTypes.NET]. * **duration** (int | None) - Automatically stop the collection after duration seconds. * **sample_ratio** (int | None) - Commands are sampled with probability 1/ratio (1 means no sampling). * **slots** (List[int] | None) - Only track keys on the specified hash slots. ``` -------------------------------- ### Install Build Tools on Ubuntu/Debian Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Install required build tools for FalkorDBLite on Ubuntu or Debian-based systems. ```bash apt-get install python3-dev build-essential ``` -------------------------------- ### aiohttp Integration with AsyncFalkorDB Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Integrate AsyncFalkorDB with aiohttp for building asynchronous web services. This example sets up an aiohttp application, defines a GET endpoint to retrieve person data using parameterized queries, and handles database connection cleanup. ```python from aiohttp import web from redislite import AsyncFalkorDB db = AsyncFalkorDB('/tmp/web.db') async def handle_get_person(request): name = request.match_info['name'] g = db.select_graph('social') # Use parameterized queries to prevent injection result = await g.ro_query( 'MATCH (p:Person {name: $name}) RETURN p.name, p.age', params={'name': name} ) if result.result_set: return web.json_response({ "name": result.result_set[0][0], "age": result.result_set[0][1] }) return web.json_response({"error": "Person not found"}, status=404) async def on_cleanup(app): await db.close() app = web.Application() app.router.add_get('/person/{name}', handle_get_person) app.on_cleanup.append(on_cleanup) web.run_app(app) ``` -------------------------------- ### Install FalkorDB Lite Source: https://github.com/falkordb/falkordblite/blob/master/README.md Install the falkordblite package using pip. This command installs the necessary Python packages for FalkorDBLite. ```console pip install falkordblite ``` -------------------------------- ### Verify FalkorDBLite Installation Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Activate your virtual environment and run the verification script to confirm a successful installation. ```bash # Activate your virtual environment first source venv/bin/activate # Run the verification script python3 verify_install.py ``` -------------------------------- ### Example Redislite Debug Output Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md This is an example of the detailed output you can expect when running the redislite.debug module from the command line, showing version, module path, and Redis server details. ```text $ python -m redislite.debug Redislite debug information: Version: 1.0.171 Module Path: /tmp/redislite/lib/python3.4/site-packages/redislite Installed Redis Server: Redis Executable: /tmp/redislite/lib/python3.4/site-packages/redislite/bin/redis-server build = 3a2b5dab9c14cd5e sha = 4657e47d:1 bits = 64 v = 2.8.17 malloc = libc Found redis-server: /tmp/redislite/lib/python3.4/site-packages/redislite/bin/redis-server v = 2.8.17 sha = 4657e47d:1 malloc = libc bits = 64 build = 3a2b5dab9c14cd5e Source Code Information Git Source URL: https://github.com/yahoo/redislite/tree/2ebd1b4d9c9ad41c78e8048fda3c69d2917c0348 Git Hash: 2ebd1b4d9c9ad41c78e8048fda3c69d2917c0348 Git Version: 1.0.171 Git Origin: https://github.com/yahoo/redislite.git Git Branch: master ``` -------------------------------- ### Install Walrus and redislite Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/using_with_existing_modules.md Install both the walrus and redislite Python packages using pip. ```shell $ pip install walrus redislite ``` -------------------------------- ### Test FalkorDBLite Installation in Python Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Perform a quick test in Python to verify the FalkorDBLite installation by creating a database, a graph, and a node. ```python from redislite.falkordb_client import FalkorDB # Create a database db = FalkorDB('/tmp/test.db') # Create a graph g = db.select_graph('test') # Run a query result = g.query('CREATE (n:Test {value: 1}) RETURN n') print(f"Success! Created node: {result.result_set}") # Cleanup g.delete() ``` -------------------------------- ### Build FalkorDBLite Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Build the project first to compile Redis and copy binaries before performing an editable install. ```bash python setup.py build ``` -------------------------------- ### Install Python Development Package (WSL) Source: https://github.com/falkordb/falkordblite/blob/master/README.md Installs the Python development package within the Bash on Ubuntu on Windows (WSL) environment. This is required for building FalkorDB Lite from source on Windows using WSL. ```bash apt-get install python-dev ``` -------------------------------- ### Install OpenMP Runtime Library on macOS Source: https://github.com/falkordb/falkordblite/blob/master/README.md If you are on macOS and encounter a 'Library not loaded' error related to libomp, install it using Homebrew. This is a runtime requirement for the FalkorDB module. ```bash brew install libomp ``` -------------------------------- ### Basic Async Redis Operations Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Demonstrates setting and getting a value using the AsyncRedis client. Ensure the database file exists and is accessible. ```python import asyncio from redislite import AsyncRedis async def main(): # Create an async Redis connection redis = AsyncRedis('/tmp/redis.db') try: # Set and get values await redis.set('key', 'value') value = await redis.get('key') print(value) # b'value' finally: await redis.close() asyncio.run(main()) ``` -------------------------------- ### Create and Query FalkorDB Graph Source: https://github.com/falkordb/falkordblite/blob/master/README.md Demonstrates creating a FalkorDB instance, selecting a graph, adding nodes and relationships using Cypher, querying the graph, and deleting the graph. This example uses the FalkorDB Graph API. ```python from redislite.falkordb_client import FalkorDB # Create a FalkorDB instance with embedded Redis + FalkorDB db = FalkorDB('/tmp/falkordb.db') # Select a graph g = db.select_graph('social') # Create nodes with Cypher result = g.query('CREATE (p:Person {name: "Alice", age: 30}) RETURN p') result = g.query('CREATE (p:Person {name: "Bob", age: 25}) RETURN p') # Create a relationship result = g.query('\ MATCH (a:Person {name: "Alice"}), (b:Person {name: "Bob"}) CREATE (a)-[r:KNOWS]->(b) RETURN r ') # Query the graph result = g.query('MATCH (p:Person) RETURN p.name, p.age') for row in result.result_set: print(row) # Read-only query result = g.ro_query('MATCH (p:Person)-[r:KNOWS]->(f) RETURN p.name, f.name') # Delete the graph when done g.delete() ``` -------------------------------- ### Manage Multiple Graphs Concurrently with AsyncFalkorDB Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Create and query different graphs for distinct domains concurrently using `asyncio.gather`. This example shows creating user and product nodes in separate graphs and then listing all available graphs. ```python async def main(): async with AsyncFalkorDB('/tmp/multi.db') as db: # Create different graphs for different domains users = db.select_graph('users') products = db.select_graph('products') # Execute queries on different graphs concurrently await asyncio.gather( users.query('CREATE (u:User {name: "Alice"})'), products.query('CREATE (p:Product {name: "Laptop"})'), ) # List all graphs graphs = await db.list_graphs() print(f"Graphs: {graphs}") asyncio.run(main()) ``` -------------------------------- ### Check PEP8 compliance Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/contributing.md Run tox to check code for PEP8 style guide conformance. Fix any reported issues before submitting code. ```bash tox -e pep8 ``` -------------------------------- ### Async Redis Operations Source: https://github.com/falkordb/falkordblite/blob/master/README.md Demonstrates asynchronous Redis key-value operations using `AsyncRedis`. Includes setting and getting values, performing multiple operations concurrently, and retrieving all keys. ```python import asyncio from redislite.async_client import AsyncRedis async def main(): # Create an async Redis connection redis_conn = AsyncRedis('/tmp/redis_async.db') # Async set and get await redis_conn.set('key', 'value') value = await redis_conn.get('key') print(value) # b'value' # Multiple operations concurrently await asyncio.gather( redis_conn.set('key1', 'value1'), redis_conn.set('key2', 'value2'), redis_conn.set('key3', 'value3'), ) # Get all keys keys = await redis_conn.keys() print(keys) await redis_conn.close() asyncio.run(main()) ``` -------------------------------- ### Running Multiple Redis Servers Source: https://github.com/falkordb/falkordblite/blob/master/README.md Starts 10 separate Redis servers and sets a unique value for 'servernumber' in each. Accesses and prints the 'servernumber' value from each server. ```python import redislite servers = {} for redis_server_number in range(10): servers[redis_server_number] = redislite.Redis() servers[redis_server_number].set('servernumber', redis_server_number) for redis_server in servers.values(): print(redis_server.get('servernumber')) # b'0' # b'1' # b'2' # b'3' # b'4' # b'5' # b'6' # b'7' # b'8' # b'9' ``` -------------------------------- ### Use Redis Key-Value Operations Source: https://github.com/falkordb/falkordblite/blob/master/README.md Shows how to perform traditional Redis key-value operations like setting and getting values using the FalkorDBLite Redis interface. This can be used alongside graph operations. ```python from redislite import Redis redis_connection = Redis('/tmp/redis.db') redis_connection.keys() # [] redis_connection.set('key', 'value') # True redis_connection.get('key') # b'value' ``` -------------------------------- ### Manually Set Up Binaries Source: https://github.com/falkordb/falkordblite/blob/master/TROUBLESHOOTING.md Manually create the bin directory, copy binaries, and set execute permissions if automatic copying fails. ```bash mkdir -p redislite/bin ``` ```bash cp build/scripts-3.13/redis-server redislite/bin/ ``` ```bash cp falkordb.so redislite/bin/ ``` ```bash chmod +x redislite/bin/redis-server ``` ```bash chmod +x redislite/bin/falkordb.so ``` -------------------------------- ### Initialize StrictRedis without a Database File Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Instantiate a StrictRedis connection without specifying a dbfilename. Each instance will get a different, temporary Redis server. This is useful for isolated testing or when persistence is not required. ```python redis_connection = redislite.StrictRedis() ``` -------------------------------- ### ZUNIONSTORE Command Example Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Union multiple sorted sets into a new sorted set with specified aggregation. Scores are aggregated based on the 'aggregate' mode (SUM, MIN, MAX, COUNT). ```python redis_connection.zunionstore(dest='new_set', keys=['set1', 'set2'], aggregate='SUM') ``` -------------------------------- ### Instantiate Redis with a Specific DB File Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Shows how to create a Redis connection instance, specifying a particular file for the Redis database. ```python redis_connection = redislite.Redis('/tmp/redis.db') ``` -------------------------------- ### Basic Async FalkorDB Operations Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Shows how to connect to an async FalkorDB instance, select a graph, create nodes with parameters, query data, and delete the graph. The database file must be accessible. ```python import asyncio from redislite import AsyncFalkorDB async def main(): # Create an async FalkorDB instance db = AsyncFalkorDB('/tmp/falkordb.db') try: # Select a graph g = db.select_graph('social') # Execute a query using parameterized queries await g.query( 'CREATE (n:Person {name: $name, age: $age}) RETURN n', params={'name': 'Alice', 'age': 30} ) # Read data result = await g.query('MATCH (n:Person) RETURN n.name, n.age') for row in result.result_set: print(row) # Clean up the graph await g.delete() finally: await db.close() asyncio.run(main()) ``` -------------------------------- ### Build HTML documentation Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/contributing.md Generate HTML documentation using tox. After building, check the output in `build/sphinx/html/index.html`. ```bash tox -e build_docs ``` -------------------------------- ### Multiple Servers with Different Configurations Source: https://github.com/falkordb/falkordblite/blob/master/README.md Sets up two Redis server instances with different configurations. One listens on a specific port, and the other acts as a read-only slave to the first. ```python import redislite master = redislite.Redis(serverconfig={'port': '8002'}) slave = redislite.Redis(serverconfig={'slaveof': "127.0.0.1 8002"}) slave.keys() # [] master.set('key', 'value') # True master.keys() # ['key'] slave.keys() # ['key'] ``` -------------------------------- ### Async Graph Database Node Creation and Relationships Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Shows creating multiple Person nodes concurrently and then establishing a KNOWS relationship between them using parameterized queries in an async FalkorDB graph. Assumes the database file exists. ```python import asyncio from redislite import AsyncFalkorDB async def main(): db = AsyncFalkorDB('/tmp/social.db') try: g = db.select_graph('social') # Create multiple nodes concurrently using parameterized queries await asyncio.gather( g.query( 'CREATE (p:Person {name: $name, age: $age})', params={'name': 'Alice', 'age': 30} ), g.query( 'CREATE (p:Person {name: $name, age: $age})', params={'name': 'Bob', 'age': 25} ), g.query( 'CREATE (p:Person {name: $name, age: $age})', params={'name': 'Carol', 'age': 28} ), ) # Create relationships using parameterized queries await g.query( ''' MATCH (a:Person {name: $name_a}), (b:Person {name: $name_b}) CREATE (a)-[:KNOWS]->(b) ''', params={'name_a': 'Alice', 'name_b': 'Bob'} ) # Query the graph result = await g.query('MATCH (p:Person) RETURN p.name, p.age') for row in result.result_set: print(f"{row[0]}, age {row[1]}") finally: await db.close() asyncio.run(main()) ``` -------------------------------- ### acl_whoami Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Gets the username for the current connection. ```APIDOC ## acl_whoami(**kwargs) -> bytes | str | Awaitable[bytes | str] ### Description Get the username for the current connection. ### Parameters * **kwargs** - Optional - Additional keyword arguments. ### Returns Returns the username (bytes or str) for the current connection, or an awaitable that resolves to the username. ``` -------------------------------- ### acl_whoami Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Gets the username for the current connection. ```APIDOC ## acl_whoami(**kwargs) ### Description Get the username for the current connection. ### Returns * bytes | str | Awaitable[bytes | str] - The username of the current connection. ``` -------------------------------- ### pid Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Get the current redis-server process id. ```APIDOC ## pid ### Description Get the current redis-server process id. ### Parameters None ### Response #### Success Response (200) * **result** (int | None) - The process id of the redis-server process associated with this redislite instance or None if the redis-server is not running. #### Response Example ```json { "result": 12345 } ``` ``` -------------------------------- ### Async FalkorDB with Context Manager Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Illustrates using AsyncFalkorDB as an async context manager for automatic resource cleanup. The database file must exist. ```python import asyncio from redislite import AsyncFalkorDB async def main(): async with AsyncFalkorDB('/tmp/falkordb.db') as db: g = db.select_graph('social') await g.query( 'CREATE (n:Person {name: $name}) RETURN n', params={'name': 'Alice'} ) result = await g.query('MATCH (n:Person) RETURN n') # Automatically closed when exiting the context asyncio.run(main()) ``` -------------------------------- ### get Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves the value associated with a given key. ```APIDOC ## get ### Description Retrieves the value associated with a given key. ### Method Not specified (likely a client library method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (bytes | str | memoryview) - Required - The key whose value is to be retrieved. ### Response #### Success Response - Returns the value associated with the key, or None if the key does not exist. ### Response Example ```json "some_value" ``` ``` -------------------------------- ### pid Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Get the current redis-server process id. ```APIDOC ## pid ### Description Get the current redis-server process id. ### Parameters None ### Response #### Success Response (200) * **pid** (int) - The process id of the redis-server process associated with this redislite instance or None if the redis-server is not running. #### Response Example ```json { "pid": 12345 } ``` ``` -------------------------------- ### Initialize StrictRedis with a Database File Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Instantiate a StrictRedis connection using a specific Redis db file. If the file exists, it will be used; otherwise, a new one will be created. This ensures data persistence and allows multiple instances to share the same Redis server process. ```python redis_connection = redislite.StrictRedis('/tmp/redis.db') ``` -------------------------------- ### get Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves the value associated with a given key. ```APIDOC ## get ### Description Retrieves the value associated with a given key. ### Method Not specified (likely a client library method) ### Endpoint Not applicable (client library method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (bytes | str | memoryview) - Required - The key whose value is to be retrieved. ### Response #### Success Response - Returns the value associated with the key, or None if the key does not exist. #### Response Example ```json "some_value" ``` ``` -------------------------------- ### FalkorDB Graph Database with Cypher Queries Source: https://github.com/falkordb/falkordblite/blob/master/README.md Demonstrates creating nodes and relationships, and querying a graph database using Cypher. Assumes a database file at '/tmp/graphs.db' and a graph named 'social'. ```python from redislite.falkordb_client import FalkorDB db = FalkorDB('/tmp/graphs.db') g = db.select_graph('social') # Create a graph with nodes and relationships g.query (''' CREATE (alice:Person {name: "Alice", age: 30}), (bob:Person {name: "Bob", age: 25}), (carol:Person {name: "Carol", age: 28}), (alice)-[:KNOWS]->(bob), (bob)-[:KNOWS]->(carol), (alice)-[:KNOWS]->(carol) ''') # Find all friends of Alice result = g.query (''' MATCH (p:Person {name: "Alice"})-[:KNOWS]->(friend) RETURN friend.name, friend.age ''') for row in result.result_set: print(f"Friend: {row[0]}, Age: {row[1]}") ``` -------------------------------- ### slowlog_len Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Gets the total number of items currently in the slow log. ```APIDOC ## slowlog_len ### Description Get the number of items in the slowlog. ### Method Not specified (likely part of a client library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **kwargs**: dict - Additional keyword arguments. ### Response * **int | Awaitable[int]**: The number of items in the slowlog. ``` -------------------------------- ### lrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Return a slice of a list between specified start and end indices. ```APIDOC ## lrange ### Description Return a slice of the list `name` between position `start` and `end`. ### Method N/A (Python method signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **name**: bytes | str | memoryview - The name of the list. - **start**: int - The starting index of the slice. - **end**: int - The ending index of the slice. ### Request Example N/A ### Response #### Success Response - **list[bytes | str]**: A list containing the elements within the specified range. ``` -------------------------------- ### lrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Return a slice of elements from a list between specified start and end indices. ```APIDOC ## lrange ### Description Return a slice of the list `name` between the `start` and `end` positions. Supports negative indices similar to Python slicing. ### Method `lrange(name: bytes | str | memoryview, start: int, end: int)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Example usage (assuming a redis client instance 'r') r.lrange('my_list', 0, 5) r.lrange('my_list', -5, -1) ``` ### Response #### Success Response - `list[bytes | str]`: A list containing the elements within the specified range. #### Response Example ```json ["element1", "element2", "element3"] ``` ``` -------------------------------- ### Basic Redis Connection and Data Operations Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Demonstrates how to establish a connection to an embedded Redis server, set a key-value pair, and retrieve the value. ```pycon >>> import redislite >>> connection = redislite.Redis() >>> connection.set('key', 'value') True >>> connection.get('key') 'value' >>> ``` -------------------------------- ### substr Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Return a substring of the string at a specified key, using start and end offsets. ```APIDOC ## substr ### Description Return a substring of the string at key `name`. `start` and `end` are 0-based integers specifying the portion of the string to return. ### Method Signature `substr(name: bytes | str | memoryview, start: int, end: int = -1) -> bytes | str | Awaitable[bytes | str]` ### Parameters * `name` (bytes | str | memoryview) - Required - The key of the string. * `start` (int) - Required - The 0-based starting offset of the substring. * `end` (int, optional) - Defaults to -1. The 0-based ending offset of the substring. ``` -------------------------------- ### substr Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Return a substring of the string at a specified key, using start and end offsets. ```APIDOC ## substr(name: bytes | str | memoryview, start: int, end: int = -1) ### Description Return a substring of the string at key `name`. `start` and `end` are 0-based integers specifying the portion of the string to return. ### Parameters #### Query Parameters - **name** (bytes | str | memoryview) - Required - The key of the string. - **start** (int) - Required - The 0-based starting offset of the substring. - **end** (int) - Optional - The 0-based ending offset of the substring. Defaults to -1 (the end of the string). ``` -------------------------------- ### getrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves a substring of a string value stored at a key, based on start and end offsets. ```APIDOC ## getrange(key: bytes | str | memoryview, start: int, end: int) ### Description Returns the substring of the string value stored at `key`, determined by the offsets `start` and `end` (both are inclusive). ### Method GETRANGE (conceptual, as this is a client-side method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **key** (bytes | str | memoryview) - The key of the string value. * **start** (int) - The starting offset (inclusive). * **end** (int) - The ending offset (inclusive). ### Request Example ```python # Example usage (actual implementation may vary) redis_client.getrange('mykey', 0, 5) ``` ### Response #### Success Response - **substring** (bytes | str) - The requested substring. #### Response Example ```json "substring" ``` ### See Also [https://redis.io/commands/getrange](https://redis.io/commands/getrange) ``` -------------------------------- ### Redis Client Instantiation from URL Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Instantiate a Redis client object by providing a connection URL. Supports redis://, rediss://, and unix:// schemes. Connection parameters can be specified in the URL or as keyword arguments, with URL parameters taking precedence. ```APIDOC ## classmethod from_url(url: str, **kwargs) -> Redis ### Description Return a Redis client object configured from the given URL. Supports `redis://`, `rediss://`, and `unix://` URL schemes. Connection details like username, password, host, port, and database can be parsed from the URL or provided as keyword arguments. URL parameters override keyword arguments. ### Method `classmethod` ### Parameters #### Path Parameters None #### Query Parameters - **db** (int) - Optional - Database number. Can also be specified in the URL path or as a keyword argument. #### Keyword Arguments - **kwargs** - Additional keyword arguments passed to the `ConnectionPool` initializer. ### Request Example ```python # Example using redis:// URL redis_client = Redis.from_url("redis://:password@localhost:6379/0") # Example using unix:// URL redis_client = Redis.from_url("unix:///path/to/socket.sock?db=0&password=password") ``` ### Response - **Redis Client Object** - A configured Redis client instance. ``` -------------------------------- ### redislite.debug.debug_info_list() Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves a list where each element is a line of debug information about the redislite installation and its associated Redis server. ```APIDOC ## redislite.debug.debug_info_list() ### Description Return a list with the debug information. ### Returns - list: A list of strings, where each string is a line of debug information. ``` -------------------------------- ### Migrating Sync API to Async API (Context Manager) Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Illustrates migrating a synchronous graph operation to an asynchronous one using context managers. ```python import asyncio from redislite import AsyncFalkorDB async def main(): async with AsyncFalkorDB('/tmp/db.db') as db: g = db.select_graph('social') result = await g.query('MATCH (n:Person) RETURN n') asyncio.run(main()) ``` -------------------------------- ### getrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Returns a substring of the string value stored at a key, based on the provided start and end offsets. ```APIDOC ## getrange(key: bytes | str | memoryview, start: int, end: int) ### Description Returns the substring of the string value stored at `key`, determined by the offsets `start` and `end` (both are inclusive). ### Method GETRANGE (Implicit) ### Endpoint /getrange ### Parameters #### Path Parameters - **key** (bytes | str | memoryview) - Required - The key of the string value. - **start** (int) - Required - The starting offset (inclusive). - **end** (int) - Required - The ending offset (inclusive). ### Response #### Success Response - Returns the specified substring of the string value. ### Response Example ```json { "example": "substring" } ``` ``` -------------------------------- ### redislite.debug.debug_info() Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves a multi-line string containing detailed debug information about the redislite installation and its associated Redis server. ```APIDOC ## redislite.debug.debug_info() ### Description Return a multi-line string with the debug information. ### Returns - multi-line string: Debug information. ``` -------------------------------- ### Run all tests Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/contributing.md Execute all tests for the project using the tox tool. This command also generates a coverage report. ```bash tox ``` -------------------------------- ### psync Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Initiates a replication stream from the master. Newer version for sync. ```APIDOC ## psync ### Description Initiates a replication stream from the master. This is a newer version for `sync`. ### Method Not specified (likely a client-side method call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **replicationid** (str) - The replication ID. * **offset** (int) - The offset for synchronization. ### Response #### Success Response * **bytes** - The replication stream data. ### Response Example ```json { "example": "" } ``` ``` -------------------------------- ### setrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Overwrites bytes in the value of a key starting at a specified offset with a new value. Extends the string if necessary. ```APIDOC ## setrange ### Description Overwrite bytes in the value of `name` starting at `offset` with `value`. If `offset` plus the length of `value` exceeds the length of the original value, the new value will be larger than before. If `offset` exceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what’s being injected. ### Method Not specified (assumed to be part of a client library call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name**: bytes | str | memoryview - The key to modify. * **offset**: int - The byte offset to start overwriting from. * **value**: bytes | bytearray | memoryview | str | int | float - The value to set. ### Response #### Success Response - **int**: The length of the new string. ### Example ```python # Example usage within a client library await redis_client.setrange(name='mykey', offset=5, value='new_data') ``` ``` -------------------------------- ### setrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Overwrites bytes in the value of a key starting at a specified offset with a new value. Extends the value if necessary. ```APIDOC ## setrange ### Description Overwrite bytes in the value of `name` starting at `offset` with `value`. If `offset` plus the length of `value` exceeds the length of the original value, the new value will be larger than before. If `offset` exceeds the length of the original value, null bytes will be used to pad between the end of the previous value and the start of what’s being injected. ### Method Not specified (likely part of a client library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name**: bytes | str | memoryview - The key to modify. * **offset**: int - The byte offset to start overwriting from. * **value**: bytes | bytearray | memoryview | str | int | float - The new value to set. ### Response * **int | Awaitable[int]**: The length of the new string. ``` -------------------------------- ### Configure Celery with redislite Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/using_with_existing_modules.md Set up Celery's broker and result backend URLs to use a redislite instance by specifying the socket file path. Ensure the Redis instance is created before configuring Celery. ```python from redislite import Redis # Create a Redis instance using redislite REDIS_DB_PATH = os.path.join('/tmp/my_redis.db') rdb = Redis(REDIS_DB_PATH) REDIS_SOCKET_PATH = 'redis+socket://%s' % (rdb.socket_file, ) # Use redislite for the Celery broker BROKER_URL = REDIS_SOCKET_PATH # (Optionally) use redislite for the Celery result backend CELERY_RESULT_BACKEND = REDIS_SOCKET_PATH ``` ```python from celery import Celery # for django projects from django.conf import settings os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings') celery_app = Celery('my_app') celery_app.config_from_object('django.conf:settings') # for other projects celery_app = Celery('my_app') celery_app.config_from_object('settings') ``` -------------------------------- ### command Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves details about all available Redis commands. ```APIDOC ## command ### Description Returns a dictionary containing details about all Redis commands. ### Method command ### Parameters * **kwargs** - Arbitrary keyword arguments. ### Returns dict[str, dict[str, Any]] | Awaitable[dict[str, dict[str, Any]]] ``` -------------------------------- ### lpos Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Get the position of a value within a list. Supports specifying rank, count of occurrences, and maximum length to scan. ```APIDOC ## lpos ### Description Get the position of `value` within the list `name`. Supports specifying rank, count of occurrences, and maximum length to scan. ### Method N/A (Python method signature) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Parameters - **name**: bytes | str | memoryview - The name of the list. - **value**: str - The value to find the position of. - **rank**: int | None - Optional. The rank of the element to return (e.g., 2 for the second occurrence, -1 for the last). - **count**: int | None - Optional. The maximum number of positions to return. If 0, returns all positions. - **maxlen**: int | None - Optional. The maximum number of list elements to scan. If 0, scans the entire list. ### Request Example N/A ### Response #### Success Response - **int | list[int] | None**: The position(s) of the value, or None if not found. ``` -------------------------------- ### lpos Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Get the position of a value within a list. Supports specifying rank, count of occurrences, and maximum length to scan. ```APIDOC ## lpos ### Description Get the position of `value` within the list `name`. Supports optional `rank` for specific occurrences, `count` for multiple positions, and `maxlen` to limit the scan. ### Method `lpos(name: bytes | str | memoryview, value: str, rank: int | None = None, count: int | None = None, maxlen: int | None = None)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Example usage (assuming a redis client instance 'r') r.lpos('my_list', 'some_value') r.lpos('my_list', 'some_value', rank=2) r.lpos('my_list', 'some_value', count=3) r.lpos('my_list', 'some_value', maxlen=1000) ``` ### Response #### Success Response - `int`: The position of the first occurrence of `value`. - `list[int]`: A list of positions if `count` is specified. - `None`: If `value` is not found and `count` is not specified. #### Response Example ```json // Single position 1 // Multiple positions [1, 5, 10] // Value not found null ``` ``` -------------------------------- ### arset Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Sets one or more contiguous values in an array starting at a specified index. Returns the number of new slots set. ```APIDOC ## arset ### Description Set one or more contiguous `values` in the array stored at `name` starting at `index`. When multiple values are provided, they are stored at consecutive indices beginning at `index`. Returns the number of new slots that were set (previously empty). ### Method N/A (Function Signature) ### Parameters - **name** (bytes | str | memoryview) - Required - The name of the array. - **index** (int) - Required - The starting index to set values. - **values** (bytes | bytearray | memoryview | str | int | float) - Required - The values to set. ### Response - **int** - The number of new slots that were set. ``` -------------------------------- ### sync Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Initiates a replication stream from the master server. ```APIDOC ## sync ### Description Initiates a replication stream from the master. ### Method Signature `sync() -> bytes | Awaitable[bytes]` ### See Also [https://redis.io/commands/sync](https://redis.io/commands/sync) ``` -------------------------------- ### Migrating Sync API to Async API (Basic) Source: https://github.com/falkordb/falkordblite/blob/master/docs/ASYNC_API.md Shows the conversion of a synchronous graph query to its asynchronous equivalent. ```python from redislite import FalkorDB db = FalkorDB('/tmp/db.db') g = db.select_graph('social') result = g.query('MATCH (n:Person) RETURN n') db.close() ``` ```python import asyncio from redislite import AsyncFalkorDB async def main(): db = AsyncFalkorDB('/tmp/db.db') g = db.select_graph('social') result = await g.query('MATCH (n:Person) RETURN n') await db.close() asyncio.run(main()) ``` -------------------------------- ### argetrange Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves values within a specified inclusive index range from an array. Supports reverse order if start > end. ```APIDOC ## argetrange ### Description Returns the values in the inclusive index range [`start`, `end`] in the array stored at `name`. If `start` is greater than `end`, elements are returned in reverse index order. ### Method Not specified (assumed to be a client library method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **name**: (bytes | str | memoryview) - The name of the array. * **start**: (int) - The starting index of the range. * **end**: (int) - The ending index of the range. ### Returns * **list[bytes | str | None]**: A list of values within the specified range. ``` -------------------------------- ### zrevrangebylex Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Retrieves a range of elements from a sorted set in reverse lexicographical order. Supports slicing with start and number of elements. ```APIDOC ## zrevrangebylex ### Description Return the reversed lexicographical range of values from sorted set `name` between `max` and `min`. If `start` and `num` are specified, then return a slice of the range. ### Method Not specified (likely a client library method) ### Endpoint Not applicable (client library method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response - **return value** (list[bytes | str]) - A list of elements in reverse lexicographical order. #### Response Example None ``` -------------------------------- ### Redis Connection URLs Source: https://github.com/falkordb/falkordblite/blob/master/docs/source/topic/redislite_module.md Examples of supported URL formats for connecting to Redis, including redis://, rediss://, and unix:// schemes. These URLs can specify connection details like username, password, host, port, and database. ```default redis://[[username]:[password]]@localhost:6379/0 rediss://[[username]:[password]]@localhost:6379/0 unix://[username@]/path/to/socket.sock?db=0[&password=password] ```