UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Lghy6QtS1exLRaY+yrGw1ZGxGNHjNbxHXhOa8p+6L8g='
WHERE
key_id = '8d58362bc4b819e02e02ee703b9bd79ebea499a31dd02e0fe971e3e7fa09e8ed'
AND (
token = 'Lghy6QtS1exLRaY+yrGw1ZGxGNHjNbxHXhOa8p+6L8g='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)