Skip to content

Add frontend locking support #2

@MatthewScholefield

Description

@MatthewScholefield

Sometimes it's useful to use an index in the database as a lock:

events = db['events']
items = events['items']
with events['lock']:
    new_uuid = str(uuid4())
    if len(items) > 0:
        items[-1]['next_uuid'] = new_uuid
    items.append({'data': 'abc', 'next_uuid': None})

db['events']['lock'] would just be a bool and the request would wait for the bool to become false, change it to true, and then return, waiting for a followup request to set it back to false.

Alternatively, this could be generalized to a type of request that waits for a value to change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions