{"id":15347653,"url":"https://github.com/michaelmior/locomotor","last_synced_at":"2025-04-15T04:13:32.827Z","repository":{"id":50200374,"uuid":"46453186","full_name":"michaelmior/locomotor","owner":"michaelmior","description":":bullettrain_front: Automatically translate Redis access in Python :snake: to server side scripts in Lua","archived":false,"fork":false,"pushed_at":"2021-06-01T23:03:25.000Z","size":1432,"stargazers_count":3,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T04:13:28.806Z","etag":null,"topics":["lua","redis","stored-procedures"],"latest_commit_sha":null,"homepage":"https://michaelmior.github.io/locomotor/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelmior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-18T23:01:43.000Z","updated_at":"2020-08-29T02:03:32.000Z","dependencies_parsed_at":"2022-09-24T07:50:45.164Z","dependency_job_id":null,"html_url":"https://github.com/michaelmior/locomotor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmior%2Flocomotor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmior%2Flocomotor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmior%2Flocomotor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmior%2Flocomotor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelmior","download_url":"https://codeload.github.com/michaelmior/locomotor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249003956,"owners_count":21196793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","redis","stored-procedures"],"created_at":"2024-10-01T11:37:17.833Z","updated_at":"2025-04-15T04:13:32.810Z","avatar_url":"https://github.com/michaelmior.png","language":"Python","readme":"# Locomotor\n\n[![Build Status](https://travis-ci.org/michaelmior/locomotor.svg?branch=main)](https://travis-ci.org/michaelmior/locomotor)\n\nLocomotor aims to automatically translate Python code which makes requests to a [Redis](https://redis.io/) server into equivalent [Lua](https://www.lua.org/) code which is executed using the [EVAL](https://redis.io/commands/eval) command.\nThis can result in significants speedups in the case where the code makes multiple requests since it avoids round trips between the server and the client.\n\nCurrently some minor work is required on the Python side.\nFirst, you should isolate the code which you want to run as a Lua script in a single function where one of the parameters is a connection to the Redis server.\nThen simply add the annotation `@locomotor.redis_server` to the function.\n\n```python\nfrom locomotor import redis_server\n\n@redis_server(redis_objs=['redis'])\ndef get_many(redis, count):\n    values = []\n    for i in range(count):\n        values.append(redis.get('KEY' + str(i)))\n\n    return values\n```\n\nIn this case, note that the parameter identifying the Redis server object was manually specified.\nThis is required if the heuristics used by Locomotor can't reliably determine how the server is accessed.\nSee [`bench/tpcc.py`](bench/tpcc.py) for an example of this determination being done automatically.\n\nThere are many limitations on the code which can be translated.\nMost of these are because certain Python constructs haven't been implemented.\nIf you hit such a case, you'll see an `UntranslatableCodeException`.\nEven if the code does appear translate correctly, you'll want to thoroughly test the translated version version.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelmior%2Flocomotor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelmior%2Flocomotor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelmior%2Flocomotor/lists"}