UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'iN5jgPfsyc8MIW4iN0vhSvyE5BO7S40vL9nV5D5PCfY='
WHERE
key_id = 'aa22d8c2859e2c760f89990cbd464c54e9ebb380b662367629818355a5e15ed3'
AND (
token = 'iN5jgPfsyc8MIW4iN0vhSvyE5BO7S40vL9nV5D5PCfY='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)