UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'G4iRB7kDvLAAjN4mXRIsWQ0gDAEeNwSnd9d4ECcDRHw='
WHERE
key_id = '38440592afa7c0f3bb1d4cddd949ee5e1e0985512b8f994b095ef87377d34019'
AND (
token = 'G4iRB7kDvLAAjN4mXRIsWQ0gDAEeNwSnd9d4ECcDRHw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)