UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'sG3oK40hRL5PPldTQi4aRr6cbnjxCtHQ+vhHip0aVrc='
WHERE
key_id = 'e0649c4d95c094783100696d765507af12831c4b7374eb0eb7f120d1b1efa056'
AND (
token = 'sG3oK40hRL5PPldTQi4aRr6cbnjxCtHQ+vhHip0aVrc='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)