UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'd3f0KN09nk4Qhs6odBwnMceqYZTCq7sZbCyX4gj5f7o='
WHERE
key_id = '6304be749ce49682171b309671dd7868b878b77e355abb46a7d7e8586aff67c5'
AND (
token = 'd3f0KN09nk4Qhs6odBwnMceqYZTCq7sZbCyX4gj5f7o='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)